[英]Unexpected __Preloader__ while loading external SWF with
I have a two files: Main.swf and DataEnter.swf. 我有两个文件:Main.swf和DataEnter.swf。 Each has a Document Class. 每个都有一个文档类。 I try to load DataEnter.swf in Main.swf. 我尝试在Main.swf中加载DataEnter.swf。
Main.as 维护
package
{
import flash.events.*;
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.display.Loader;
public class Main extends MovieClip
{
public function Main()
{
var loader: Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, DataEnter_loadComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
loader.load(new URLRequest('DataEnter.swf'));
}
function DataEnter_loadComplete(evt: Event):void
{
trace(evt.target.content); // DataEnter__Preloader__
var SWF = evt.target.content;
SWF.FooBar(); //Error #1069: Property FooBar not found on DataEnter__Preloader__ and there is no default value
}
}
}
DataEnter.as 数据输入
package
{
import flash.display.Sprite;
public class DataEnter extends Sprite
{
private var _socketWorker:Foo;
public function setSocketWorker(sw:Foo)
{
_socketWorker = sw;
}
public function FooBar()
{
//do something
}
}
}
When occurs an event Event.COMPLETE of Loader in Main class, the evt.target.content contains object DataEnter_ Preloader _ . 当发生Main类中Loader的Event.COMPLETE事件时, evt.target.content包含对象DataEnter_ Preloader _ 。 But it must be " DataEnter ". 但是它必须是“ DataEnter ”。
What is wrong? 怎么了? How to call method FooBar of Loaded Class ? 如何调用Loaded类的FooBar方法?
您是否有机会使用扩展的ActionScript设置面板的“运行时共享库”部分中的预加载器选项?
I was running into this problem as well. 我也遇到了这个问题。 After backtracking, it turned out that adding an embedded font to the data swf caused it. 回溯之后,事实证明,向数据swf添加嵌入式字体会导致这种情况。
I recommend removing any embedded fonts from the DataEnter.FLA, and republishing the SWF, to get this to work 我建议从DataEnter.FLA中删除所有嵌入的字体,然后重新发布SWF,以使其正常工作
I opened DataEnter.swf in FlashDevelopIDE . 我在FlashDevelopIDE中打开了DataEnter.swf。 This shows that my file has two frames, but FlashIDE it has only one frame. 这表明我的文件有两帧,但FlashIDE只有一帧。
In DocumentClass of DataEnter I have included a class "Foo", which works with sockets. 在DataEnter的DocumentClass中,我包括了一个用于套接字的“ Foo”类。 But, object of this class, passed in constructor. 但是,此类的对象在构造函数中传递。
When I removed the class "Foo" and publish file again, then on loading swf file *DataEnter_Preloader_* is gone, and expected DataEnter was there. 当我删除类“ Foo”并再次发布文件时,在加载swf文件时,* DataEnter_Preloader_ *消失了,并且期望那里有DataEnter 。
Sorry for Bad English 对不起,英语不好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.