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

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

问题描述

我有一些从 UIComponent 派生的自定义组件.我重载了 updateDisplayList,因此它们具有自定义外观.我创建了一个布局器来布置这些自定义组件,但要正确放置它们,我必须知道自定义组件的宽度、高度.它们是动态创建的.在所有这些创建之后(为每个创建的 createCompleted 事件触发),我尝试对它们进行布局,但宽度/高度属性仍然为 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 文档,了解有关实现您自己的 UIComponents 的更多信息——这里有大量信息可供阅读,但如果您直接从 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天全站免登陆