在一个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);
}
比如如下代码:
<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);
}
相关文章推荐
- 扩展银行项目,添加一个(客户类)Customer类。Customer类将包含一个Account对象。
- 一个ArrayList<Integer>的一个对象,我想在这个集合中添加一个字符串数据,如何实现呢
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- QTextEdit添加文本对象(将N个文字结合成一个整体)
- Python: 为对象动态添加函数,且函数定义来自一个str
- AS3 EaseSprite --- 简单的按钮,带鼠标经过时,缓动式的缩放大小的一个显示对象
- 一个组合类问题,对象添加不上,错误!,忘高手探讨!!
- 为某一个对象动态添加属性
- 添加一个对象到集合中时,集合里面存放的是对象的引用还是对象本身?
- Unreal4 简单创建一个c++项目,并给对象添加材质
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- 在Flex项目中的容器添加Sprite孩子
- 在Sprite 基础之上创建一个既可以控制移动,也可以动画的对象定义。
- Flex中如何给一个按钮添加链接,点击链接打开一个网页呢?
- Flex中如何利用titleIcon属性给Panel容器标题部添加一个ICON图标的例子
- list列表中添加多个【只修改了一个属性的对象】
- Flex一个RemoteObject调用JAVA对象里面的多个方法
- 完成一个学生管理程序,使用学号作为键添加5个学生对象,并可以将全部信息保存在文件中,可以实现对学生信息的学号查找,输出全部学生信息的功能。
- Flex中如何通过prompt属性在ComboBox控件中添加一个提示项(prompt)的例子
- Flex中如何给一个按钮添加链接,点击链接打开一个网页呢?