AS3预加载器代码没有进展

时间:2013-03-13 20:31:25

标签: actionscript-3 flash preloader

在我的FLV文件中第一帧我有这个预加载器代码:

//Stop Frame
stop();

//Create a listener to call the loading function as the movie loads
this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, loading);

//Runs when the loading progress has changed
    function loading(event:ProgressEvent):void
    {

    //Determine the percent loaded from bytesLoaded and bytesTotal
    var percent:Number = event.bytesLoaded / event.bytesTotal * 100;

    //Display the percentage of the pre-loaded MovieClip
    percentage_text.text = int(percent)+"%";

        if(percent == 100){
            gotoAndStop(2);
        }
    }

当我尝试通过绝对路径"http://localhost/test/mainFLV.swf"从Xampp服务器运行SWF文件时,SWF不会超过0%。但是,当我将SWF嵌入PHP脚本并加载PHP脚本时,SWF加载,但它没有显示预加载器的进度。

任何帮助?

修改

刚刚在Firefox中对它进行了测试,并且在进入第二帧之前,我得到了预加载器的闪存为62%。但是原始问题仍然存在于Chrome中。

1 个答案:

答案 0 :(得分:1)

当您在本地主机上测试时,PROGRESS事件经常会频繁发生,因此有时它会被检测不到。如果文件也被浏览器缓存,则会发生这种情况。

您应该侦听事件COMPLETE以确定文件是否已加载。

修改

您可以将文件上传到慢速服务器;-)或者,出于测试目的,使用网络速度限制软件。

但老实说,如果预加载器在正常情况下(平均速度连接)过快,则意味着不需要它。用户可以等一两秒......你可以使用'旋转的东西'来代替。