我正在使用Flash Builder 4.7和Flash Professional CS6创建的项目,很不错。 我需要项目加载是“预加载的SWF”中的SWF,
第一个SWF,加载第二个SWF,
第二个SWF将成为该项目的“主页”。
此时,它的工作非常完美。但是当“Home”尝试加载其他外部SWF时,它会说:
[IOErrorEvent type =“ioError”bubbles = false cancelable = false eventPhase = 2 text =“Error#2124”]
第一个SWF的代码:
public class InitialSWF extends MovieClip
{
private var _loader_:Loader;
private var _applicationContent_:DisplayObject;
private var _loaderContent_:MovieClip;
private var _loaderIcon_:MovieClip;
public function InitialSWF()
{
super();
_loader_ = new Loader();
_loader_.contentLoaderInfo.addEventListener(Event.COMPLETE,_onComplete_,false,0,true);
_loader_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,_onIoError_,false,0,true);
_loader_.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,_onProgress_,false,0,true);
_loader_.load(new URLRequest("Home.swf"));
}
private function _onComplete_(param1:Event) : void
{
_applicationContent_ = _loader_.content;
_applicationContent_.visible = true;
stage.addChild(_applicationContent_);
_applicationContent_.addEventListener("onApplicationComplete",_onApplicationComplete_,false,0,true);
_loader_.contentLoaderInfo.removeEventListener(Event.COMPLETE,_onComplete_);
_loader_.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,_onIoError_);
_loader_.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,_onProgress_);
_loader_.unload();
_loader_ = null;
}
private function _onApplicationComplete_(tmpEvt:Event) : void
{
_applicationContent_.removeEventListener("onApplicationComplete",_onApplicationComplete_);
_loaderContent_.addEventListener("loaderOut",_onLoaderOut_,false,0,true);
// do something
}
private function _onLoaderOut_(param1:Event) : void
{
_loaderContent_.removeEventListener("loaderOut",_onLoaderOut_);
_applicationContent_.visible = true;
stage.removeChild(this);
}
private function _onIoError_(tmpError:IOErrorEvent) : void
{
trace(tmpError);
}
private function _onProgress_(param1:ProgressEvent) : void
{
var _progress_:Number = Math.round(param1.bytesLoaded / param1.bytesTotal * 100);
//Do animation loading
}
HomeSWF:
public class SecondarySWF extends Sprite
{
private var _loader_:Loader;
private var _loaderContent_:MovieClip;
private var _loaderIcon_:MovieClip;
private var _applicationContent_:DisplayObject;
public function SecondarySWF()
{
this.addEventListener(Event.ADDED_TO_STAGE,this._GoLogin_,false,0,true);
}
public function _GoLogin_(tmpEvent:Event)
{
_loader_ = new Loader();
_loader_.contentLoaderInfo.addEventListener(Event.COMPLETE,_onComplete_,false,0,true);
_loader_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,_onIoError_,false,0,true);
_loader_.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,_onProgress_,false,0,true);
_loader_.contentLoaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
_loader_.load(new URLRequest("SecondarySWF.swf"));
}
private function httpStatusHandler(event:HTTPStatusEvent):void {
trace(event);
}
private function _onComplete_(param1:Event) : *
{
_applicationContent_ = _loader_.content;
_applicationContent_.visible = true;
stage.addChild(_applicationContent_);
_applicationContent_.addEventListener("onApplicationComplete",_onApplicationComplete_,false,0,true);
_loader_.contentLoaderInfo.removeEventListener(Event.COMPLETE,_onComplete_);
_loader_.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,_onIoError_);
_loader_.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS,_onProgress_);
_loader_.unload();
_loader_ = null;
this.removeEventListener(Event.ADDED_TO_STAGE,this._GoLogin_);
}
private function _onApplicationComplete_(param1:Event) : void
{
_applicationContent_.removeEventListener("onApplicationComplete",_onApplicationComplete_);
_loaderContent_.addEventListener("loaderOut",_onLoaderOut_,false,0,true);
// ..
}
private function _onLoaderOut_(param1:Event) : void
{
_loaderContent_.removeEventListener("loaderOut",_onLoaderOut_);
//_applicationContent_.visible = true;
//stage.removeChild(this);
}
private function _onIoError_(tmpError:IOErrorEvent) : void
{
trace(tmpError);
}
private function _onProgress_(param1:ProgressEvent) : void
{
var _progress_:Number = Math.round(param1.bytesLoaded / param1.bytesTotal * 100);
// ..
}
}
ConsoleChromeSWF< - 这是Google console.log的图片,请注意:
- 启动InitialSWF
- 加载HomeSWF
- 完成HomeSWF的装载
- 启动HomeSWF
- 辅助SWF的链接(审查/隐藏公开)
- 加载SecondarySWF
- ERROR
我不知道为什么辅助SWF是100%加载但返回错误...问候!