As3 预加载器(100% 之前为空白)
我有一个包含两个框架的 FLA 文件。在第一帧上,我只有一个文本字段和一些用于预加载的代码。预加载完成后,它会 gotoAndStop(2)
在第 1 帧上,我有:
stop();
stage.scaleMode = StageScaleMode.SHOW_ALL;
//Import the required assets
import flash.display.*;
//Stop the playhead while loading occurs
this.stop();
//Create a listener to call the loading function as the movie loads;
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, PL_LOADING);
this.loaderInfo.addEventListener(Event.COMPLETE, PL_FINISH);
function PL_LOADING(event:ProgressEvent):void
{
var pcent:Number = event.bytesLoaded / event.bytesTotal * 100;
//Display the % loaded in textfield
txt.text = int(pcent) + "%";
//If the movie is fully loaded, kick to the next frame on the main timeline
}
function PL_FINISH(event:Event):void
{
removeChild(txt);
gotoAndStop(2);
}
在第 2 帧上,我什么都没有,除了:
var game:Game = new Game();
addChild(game);
在我的发布商设置中,我已导出到第 2 帧。
我的问题是预加载器赢了直到 100% 才显示。有谁知道为什么?
PS 为了测试,我在第 2 帧的舞台上放置了一个大图像文件,结果是相同的。
I have an FLA file with two frames. On the first frame I have nothing but a textfield and some code to do the preloading. After it is done preloading it does gotoAndStop(2)
On frame 1 I have:
stop();
stage.scaleMode = StageScaleMode.SHOW_ALL;
//Import the required assets
import flash.display.*;
//Stop the playhead while loading occurs
this.stop();
//Create a listener to call the loading function as the movie loads;
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, PL_LOADING);
this.loaderInfo.addEventListener(Event.COMPLETE, PL_FINISH);
function PL_LOADING(event:ProgressEvent):void
{
var pcent:Number = event.bytesLoaded / event.bytesTotal * 100;
//Display the % loaded in textfield
txt.text = int(pcent) + "%";
//If the movie is fully loaded, kick to the next frame on the main timeline
}
function PL_FINISH(event:Event):void
{
removeChild(txt);
gotoAndStop(2);
}
On frame 2 I have nothing except:
var game:Game = new Game();
addChild(game);
In my publisher settings I have export to frame 2.
My problem is that the preloader won't display until 100%. Does anyone know why?
P.S. For testing I put a large image file on the stage in frame 2 and the result is the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您没有在为 ActionScript 导出的每个库元件中取消选择“在第 1 帧中导出”,通常会发生这种情况。
您需要确保创建对这些对象的引用(以便 ActionScript 可以访问它们)将它们放置在第 2 帧的舞台上(视线之外)。
发生的情况是在预加载器本身加载之前加载所有符号。
如果这不是问题,请提供一些代码,以便我可以更好地评估您的问题。
This normally happens if you haven't deselected "Export in frame 1" in each of the library symbols that you are exporting for ActionScript.
You'll need to make sure that you create reference to these objects (so that ActionScript can access them) by placing them onto the stage in frame 2 (out of sight).
What's happening is that all of the symbols are being loaded before the preloader itself has loaded.
If this isn't the issue, then please provide some code so I can better assess your issue.
您是否尝试过在第一帧上放置一些静态的东西?仅仅因为有一个预加载器,并不意味着您的 swf 会完全显示...
我知道我曾经有过一个 swf,由于网络延迟,只花了一分钟时间才真正让 Flex 预加载器显示出来。可能是您的 swf 在 90% 已加载后才显示。
Have you tried putting something static on frame one? Just because there is a preloader, that doesn't mean that your swf will be displaying at all...
I know that I had one swf once which simply took a minute to actually get the Flex preloader to even show up because of network latency. It could be that your swf isn't displaying until 90% of it has already loaded.
我正在处理类似的问题,并且我发现了一些事情:我的防病毒软件包含一种“浏览器保护”功能,该功能会在允许浏览器实际显示它们之前提前检查所有文件。如果系统上尚未安装此防病毒功能,则预加载器可以正常工作。我检查了其他一些带有 Flash 内容的网站,在这些情况下它们的行为也“错误”。现在,有些人似乎找到了一种方法来阻止防病毒软件乱搞,但我不知道他们是如何做到的......还没有......
I´m dealing with similar problems, and there is something i found out: my antivirus contains a kind of "browser protection" feature, which sort of checks all files in advance before it allows the browser to actually display them. If this antivirus feature has not been installed on the system, the preloader works beautifully. I´ve checked some other web-sites with flash content, and they also behave "wrong" under these circumstances. Now, some people seem to have found a way to stop the antivirus from messing around, but i don´t know how they do it... not yet...