您的位置:首页 > 大数据 > 人工智能

在一个Flex Container中添加Sprite 对象

2010-08-16 10:28 316 查看
在flex 中, 直接向一个container (如: Canvas Panel) 对象中添加 Sprite 是不行的.

比如如下代码:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import com.roguedevelopment.pulse.PulseEngine;
import com.roguedevelopment.pulse.simple.SimpleParticles;
import mx.core.FlexSprite;
public function ShowIt(e:Event):void
{
var bg:FlexSprite=new FlexSprite();
canvas.addChild(bg);
}
]]>
</mx:Script>
<mx:Canvas x="35.5" y="20" width="377" height="289" id="canvas">
<mx:Button x="10" y="20" label="Show!" id="btnShow" click="ShowIt(event)" width="65"/>
</mx:Canvas>
</mx:Application>

会报类型错误

TypeError: Error #1034: Type Coercion failed: cannot convert mx.core::FlexSprite@40b5271 to mx.core.IUIComponent.

应该用rawChildren属性

public function ShowIt(e:Event):void
{
var bg:FlexSprite=new FlexSprite();
canvas.rawChildren.addChild(bg);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐