获取动态创建的自定义uicomponent的宽度 [英] get width of dynamically created custom uicomponent

查看:111
本文介绍了获取动态创建的自定义uicomponent的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些自定义组件,这些组件是从UIComponent派生的.我重载了updateDisplayList,因此它们具有自定义外观.我创建了一个布局器,用于布局这些自定义组件,但是要正确放置它们,我必须知道自定义组件的宽度,高度.它们是动态创建的.在创建所有它们之后(为每个事件触发creationCompleted事件),我尝试对它们进行布局,但是width/height属性仍然为0. 在布局过程之前,我还试图将它们添加到画布中.

I have some custom components, that derived from UIComponent. I overloaded the updateDisplayList so they have custom look. I've created a layouter that lays out these custom components, but to place them correctly, I have to know the custom componets width, height. They are created dynamically. After all of them created (creationCompleted event fired for every), i try to laying out them, but width/height property is still 0. I am also tried to add them to a canvas, before the layout process.

所以我的问题是,如何创建动态放置的自定义UIComponent,并了解其宽度和高度.

So my question is, how to create custom UIComponent that placed dynamically, and get to know the width and height of it.

谢谢

使用mx_internal命名空间,我可以设置宽度和高度(使用内部的$ width和$ height字段),看起来好像可以正常工作.但不是那么干净/好的解决方案.

With the use of the mx_internal namespace I can set width and height (using the internal $width and $height fields), and it looks like it is working. But not so clean/good solution.

推荐答案

如果您是继承自UIComponent,而不是继承自其子类之一,则可能需要确保实现了measure()方法等等.在此处查看Flex文档,以获取有关实现自己的UIComponent的更多信息-这里有很多信息可以阅读,但是如果您直接从UIComponent派生,那么您可能应该知道这一切:

If you're inheriting from UIComponent, rather than from one of its subclasses, you'll probably want to make sure you're implementing the measure() method, among others. Check out the Flex docs here for more information on implementing your own UIComponents -- there's a good bunch of info to read here, but it's all stuff you should probably know if you're deriving from UIComponent directly:

http://www.adobe .com/livedocs/flex/3/html/help.html?content = ascomponents_advanced_3.html

希望有帮助!您也可以尝试发布一些代码,只是为了让我们有一些更具体的内容.但是有可能,您只是没有实现应获取的东西而已. (而且您的直觉是正确的-您不必为了获得所需的内容而深入研究mx_internal.)

Hope it helps! You might also try posting a little code, just so we have something more specific to go on. But chances are, you're just not implementing something you should be in order to retrieve those values. (And your instinct is correct -- you shouldn't have to dig into mx_internal in order to get what you need.)

这篇关于获取动态创建的自定义uicomponent的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆