开发者

IE not supporting as3 preloader action

开发者 https://www.devze.com 2023-03-19 17:20 出处:网络
I have used the below code. stop(); this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadingAction);

I have used the below code.

stop();
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoadingAction);
this.loaderInfo.addEventListener(Event.COMPLETE, onLoadedAction);
this.loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErroAction);
function onLoadingAction (e:ProgressEvent):void 
{
    trace("loading");   
}
function onLoadedAction (e:Event):void 
{
    this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onLoadingAction);
    gotoAndStop(currentFrame+1);
}
function ioErroAction (e:IOError):void 
{
    开发者_开发技巧trace("Dev Ben " + e.toString());
}

This code is supporting for chrome and firefox. But if I run using IE, its stuck with onLoadingAction.

What do I needs to do to run in IE?


Unfortunately, the COMPLETE event of the root loaderInfo isn't reliable and behaves differently in different browsers. It will fail to fire in some browsers if the file is cached or running locally.

Instead, checked that loaderInfo.bytesLoaded == loaderInfo.bytesTotal in an ENTER_FRAME or TIMER handler:

addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(event:Event):void
{
    if(loaderInfo && loaderInfo.bytesLoaded == loaderInfo.bytesTotal)
    {
        // load complete
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消