AS3 preloader不工作的浏览器,但会在Flash Professional [英] AS3 Preloader not working in browser, but does in Flash Professional

查看:183
本文介绍了AS3 preloader不工作的浏览器,但会在Flash Professional的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得,我加了preloader现场的SWF。在preloader正常工作时,我按下Ctrl + Enter键在Flash CS4中,选择查看>模拟下载。

在preloader显示,和充分的时候,这部电影将继续按预期的方式。

不过,我一时嵌入到SWF到一些HTML和负载从本地主机在任何浏览器,影片并没有继续下去,直到我点击右键并选择播放。

当我用查尔斯Web调试代理工具和油门的连接,然后再次preloading正常工作,并完成当电影收益?

任何想法可能是想错了吗?这里的来源为preloader:

 进口flash.events.ProgressEvent;

loaderInfo.addEventListener(使用ProgressEvent.PROGRESS,更新);

功能更新(E:ProgressEvent):无效
{
    VAR%的:数= Math.floor((e.bytesLoaded * 100)/ e.bytesTotal);

    如果(preloaderClip为影片剪辑)
    {
        preloaderClip.gotoAndStop(百分比);
    }

    如果(百分之== 100)
    {
        玩();
    }
}

//额外的测试的IE浏览器
VAR%的:数=
    Math.floor((this.loaderInfo.bytesLoaded * 100)/ this.loaderInfo.bytesTotal);

如果(百分之== 100)
{
    nextFrame();
}
停止();
 

解决方案

耶!修正了吧!我只是增加了一个ADDED_TO_STAGE事件侦听器具有以下code:

 私有函数onAddedToStage(事件:事件):无效
{
    VAR%的:数=
        Math.floor((this.loaderInfo.bytesLoaded * 100)/ this.loaderInfo.bytesTotal);

    MonsterDebugger.trace(这一点,ADDED_TO_STAGE+百分比+加载中...);

    如果(百分之== 100)
    {
        的gotoAndPlay(中,主);
    }
}
 

I've got a SWF to which I added a Preloader scene. The preloader works fine when I hit Ctrl+Enter in Flash CS4, and select View > Simulate Download.

The preloader displays, and when full, the movie continues as expected.

However, the moment I embed the SWF into some HTML, and load from localhost in any browser, the movie doesn't continue until I right click and select Play.

When I use the Charles Web Debugging Proxy tool and throttle the connection, then again preloading works fine, and the movie proceeds when done?

Any idea what might be going wrong? Here's the source for the preloader:

import flash.events.ProgressEvent;

loaderInfo.addEventListener(ProgressEvent.PROGRESS, update);

function update(e:ProgressEvent):void
{
    var percent:Number = Math.floor((e.bytesLoaded * 100) / e.bytesTotal);

    if(preloaderClip is MovieClip)
    {
        preloaderClip.gotoAndStop(percent);
    }

    if(percent == 100)
    {
        play();
    }
}

// Extra test for IE
var percent:Number = 
    Math.floor((this.loaderInfo.bytesLoaded * 100) / this.loaderInfo.bytesTotal);

if(percent == 100)
{
    nextFrame();
}
stop();

解决方案

Yay! Fixed it! I simply added an ADDED_TO_STAGE event listener with the following code:

private function onAddedToStage(event:Event):void
{
    var percent:Number = 
        Math.floor((this.loaderInfo.bytesLoaded * 100) / this.loaderInfo.bytesTotal);

    MonsterDebugger.trace(this, "ADDED_TO_STAGE " + percent + " loaded...");

    if(percent == 100)
    {
        gotoAndPlay("in", "Main");
    }
}

这篇关于AS3 preloader不工作的浏览器,但会在Flash Professional的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆