Adobe Flash Builder (flex4):addChild() 在此类中不可用。

发布于 2024-08-17 07:00:27 字数 926 浏览 6 评论 0原文

我想将 swf 加载到 flex 4 应用程序中以便使用它的类。

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]

如果我更改 addChild()< /code> 到 addElement(),我收到以下编译错误:

1067:将 flash.display:Loader 类型的值隐式强制转换为不相关的类型 mx.core:IVisualElement。 main.mxml 路径/目录第 22 行 Flex 问题

有什么想法可以解决此问题吗?

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); }

I receive the error:

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]

If I change addChild() to addElement(), I receive the following compilation error:

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

微暖i 2024-08-24 07:00:27

创建另一个容器来放置 displayObject:

// container ( IVisualElement ) for DisplayObjects
var container:UIComponent = new UIComponent();
addElement( container );

// displayObject goes to container
var displayO:Sprite = new Sprite();
container.addChild( displayO );

Create another container to place the displayObject in:

// container ( IVisualElement ) for DisplayObjects
var container:UIComponent = new UIComponent();
addElement( container );

// displayObject goes to container
var displayO:Sprite = new Sprite();
container.addChild( displayO );
浅唱ヾ落雨殇 2024-08-24 07:00:27

在flash builder 4完整版中,没有任何this.rawChildren。

解决该问题的最佳方法是将每个所需的类转换为 Flex 组件并在您的 Flex 应用程序中使用它:

  1. 下载并安装 Flex 组件套件
    http://www.adobe.com/cfusion/entitlement/index.html cfm?e=flex_skins

  2. 创建影片剪辑

  3. 转换为 Flex 组件

  4. 将相关函数添加到此类< /p>

该类是附加到即将转换为 Flex 组件的影片剪辑的类的骨架:

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();
    }
}
} 

well in flash builder 4 full version, there isn't any this.rawChildren.

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:

  1. download and install flex component kit
    http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex_skins

  2. create a movie clip

  3. convert to flex component

  4. add the relevant functions to this class

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();
    }
}
} 
念﹏祤嫣 2024-08-24 07:00:27

this.rawChildren.addChild( ldr )
应该有效

this.rawChildren.addChild( ldr )
should work

七颜 2024-08-24 07:00:27
private var _loader:SWFLoader = new SWFLoader();
private var _uicomponent:UIComponent = new UIComponent();
private function swfLoaded(event:Event):void 
{
Alert.show("inside swf Loaded");
var content:DisplayObject =_loader.content;
_uicomponent.addChild(content);
} 
public function loadSWF () : void 
{   

_loader.addEventListener(Event.INIT, swfLoaded);
_loader.load("http://intelliveysoft.com:5080/myelearn/Admin.swf"); 
addElement(_uicomponent);
}

试试这个。会起作用的

private var _loader:SWFLoader = new SWFLoader();
private var _uicomponent:UIComponent = new UIComponent();
private function swfLoaded(event:Event):void 
{
Alert.show("inside swf Loaded");
var content:DisplayObject =_loader.content;
_uicomponent.addChild(content);
} 
public function loadSWF () : void 
{   

_loader.addEventListener(Event.INIT, swfLoaded);
_loader.load("http://intelliveysoft.com:5080/myelearn/Admin.swf"); 
addElement(_uicomponent);
}

Try this. It will work

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文