现在的位置: 首页 > 综合 > 正文

将Sprite控件添加到FLEX UI中

2018年03月30日 ⁄ 综合 ⁄ 共 527字 ⁄ 字号 评论关闭

   在Flex的帮助文档里,有很多例子都是扩展Sprite类的。如果想把这些实例添加到你的mx:Application中,如:addChild(DisplayObject ),肯定会出错。错误的大致意思是:flash.display::Sprite没有实现mx.core.IUIComponent接口。
    Sprite->DisplayObjectContainer ->InteractiveObject ->DisplayObject ->EventDispatcher ->Object
从Sprite的继承关系来看,它虽然是DIsplayObject但是它没有实现IUIComponent,不能直接添加到Flex组件里是当然的了。
    Flex文档上指出所有的可视化控件都继承自UIComponent 而它自己是实现了IUIComponent 接口的。UIComponent 允许添加Sprite和MovieClip。
经常使用到的做法是:
   var comp: UIComponent = new UIComponent();
   comp.addChild(sprite);
   cavas1.addChild(comp);
这样flash控件就能正常在flex组件里显示了。

抱歉!评论已关闭.