Adobe Flash Builder (flex4):addChild() 在此类中不可用. [英] Adobe Flash Builder (flex4): addChild() is not available in this class.
问题描述
我想将 swf 加载到 flex 4 应用程序中以使用其类.
I want to load an swf into a flex 4 application in order to use its classes.
var ldr:Loader=new Loader();
ldr.load(new URLRequest("file://path/to/fileswf"));
ldr.contentLoaderInfo.addEventListener(Event.INIT, loaded);
function loaded(evt:Event):void { addChild(ldr); }
我收到错误:
错误:addChild() 在此类中不可用.相反,使用 addElement() 或修改皮肤(如果有).
在 spark.components.supportClasses::SkinnableComponent/addChild()[E:\dev\gumbo_beta2\frameworks\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:966]
在 main/private:init/loaded()[C:\Documents and Settings\ufk\Adobe Flash Builder Beta 2\xpogames-toolkit-test\src\main.mxml:22]
Error: addChild() is not available in this class. Instead, use addElement() or modify the skin, if you have one.
at spark.components.supportClasses::SkinnableComponent/addChild()[E:\dev\gumbo_beta2\frameworks\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:966]
at main/private:init/loaded()[C:\Documents and Settings\ufk\Adobe Flash Builder Beta 2\xpogames-toolkit-test\src\main.mxml:22]
如果我将 addChild()
更改为 addElement()
,我会收到以下编译错误:
If I change addChild()
to addElement()
, I receive the following compilation error:
1067:将 flash.display:Loader 类型的值隐式强制转换为不相关的 mx.core:IVisualElement 类型.main.mxml 路径/目录第 22 行 Flex 问题
1067: Implicit coercion of a value of type flash.display:Loader to an unrelated type mx.core:IVisualElement. main.mxml path/dir line 22 Flex Problem
任何想法如何解决这个问题?
Any ideas how to resolve this issue?
推荐答案
在 flash builder 4 完整版中,没有任何 this.rawChildren.
well in flash builder 4 full version, there isn't any this.rawChildren.
解决该问题的最佳方法是将每个必需的类转换为 flex 组件并在您的 flex 应用程序中使用它:
The best approach to resolve the issue would be to convert each required class to a flex component and to use it on your flex application:
创建影片剪辑
转换为弹性组件
给这个类添加相关函数
附加到即将转换为 flex 组件的影片剪辑的类的骨架:
a skeleton for a class that is attached to a movieclip that is about to be converted to a flex component:
package {
import mx.flash.UIMovieClip;
import flash.text.TextField;
import flash.events.Event;
import flash.events.MouseEvent;
public dynamic class challenge_screen extends UIMovieClip {
public function challenge_screen() {
super();
}
}
}
这篇关于Adobe Flash Builder (flex4):addChild() 在此类中不可用.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!