gpt4 book ai didi

apache-flex - Adobe Flash Builder(flex4): addChild() is not available in this class.

转载 作者:行者123 更新时间:2023-12-03 09:46:39 26 4
gpt4 key购买 nike

我想将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); }

我收到错误:

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(),则会收到以下编译错误:

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



任何想法如何解决这个问题?

最佳答案

创建另一个容器以将displayObject放置在:

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

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

关于apache-flex - Adobe Flash Builder(flex4): addChild() is not available in this class.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2023632/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com