【发布时间】:2012-02-12 21:10:30
【问题描述】:
我要解决的基本问题是,我混合了 Flex 和 Flash 组件,并且我有一个通用函数,用于向组件添加进度微调器。所以如果组件是Container,我就添加到rawChildren,否则正常添加。
但是,我遇到了从 VBox 继承的组件的问题。我打电话
cont.rawChildren.addChildAt(spinner, cont.rawChildren.numChildren);
但是当我追踪孩子们时,我的微调器出现在cont.getChildren() 中,comp.numChildren 显然也增加了 1。并且其他容器似乎工作正常,甚至其他 VBox 控件。
我浏览了 Flex 框架代码,但找不到任何东西来解释为什么会发生这种情况,无论是通过继承还是计时。
有没有人看到过类似的情况或可以解释为什么rawChildren 在这种情况下可能无法预测?
谢谢。
功能:
var bcu:Number = u.numChildren;
var bce:Number = el.numChildren;
el.addChildAt(s, ((pos > -1)?pos : el.numChildren));
trace("ADD NEW SPINNER", u, el, el.numChildren, u.numChildren, bce, bcu);
el 是容器的 DisplayObject 或 rawChildren 对象,u 是微调器附加到的原始对象。
输出:
ADD NEW SPINNER BlockMovePopup1734 [object ContainerRawChildrenList] 6 5 5 4
然后:
[Fault] exception, information=TypeError: Error #1034: Type Coercion
failed: cannot convert com.misc::SbSpinner@57970a1 to mx.core.IUIComponent.
输出显示el 正确设置为ContainerRawChildrenList(VBox 的rawChildren 对象)并且numChildren 在调用之前是[6,5] 与[5,4]。这意味着 Sprite 被添加到内容子项而不是 rawChildren。
【问题讨论】:
-
您说的是哪个“内容儿童”?您说“但是,我遇到了从 VBox 继承的组件的问题”,但您没有准确解释从 VBox 扩展的类会发生什么。
-
“内容子项”是容器的正常子项,不包括添加到 rawChildren 的皮肤之类的东西。我的扩展 VBox 本质上只是一个弹出/工具提示类型的东西,但对孩子没有什么特别的。它最多包含 4 个链接按钮。
标签: actionscript-3 apache-flex flex3