AS3预加载器悲伤,无法从库加载符号

发布于 2024-08-21 05:09:07 字数 548 浏览 10 评论 0原文

我创建了一个 AS3 预加载器,并将其代码放置在第一帧上。

然后我制作了一个符号,并将其放入库中。它被设置为在第 1 帧上不导出,并且 fla 的设置在第 2 帧上导出所有类。直到第二帧才出现对该对象的引用。

然后,每当我在没有选中“在第一帧中导出”框的情况下进行编译时,闪存就会崩溃。

为了解决这个问题,一位朋友建议我在第 3 帧上开始游戏逻辑,这样它将正确加载第 2 帧。这似乎工作正常,该类正在正确实例化。

然后,事实证明它没有加载影片剪辑,只是实例化了该类。同样,这个问题可以通过在第 1 帧中导出来解决,但我真的负担不起这样做。

这位朋友建议我在第 3 帧的舞台上放置一个符号实例,并在第 4 帧上执行游戏逻辑。他们说这将正确初始化影片剪辑。

然而,事实并非如此。如何加载整个符号、图形等,而不导出到第 1 帧?这个单个符号可能包含 10-20 MB 的图形,因此需要预加载。

感谢您的帮助!

编辑:长话短说,我所需要的只是某种方式来加载影片剪辑,以便它可以使用和可见以及一切。

编辑:有没有办法通过 AS3 强制加载影片剪辑?

I created an AS3 preloader, and placed the code for that on frame one.

I then made a symbol, and placed it in the library. It was set to NOT export on frame 1, and the fla's settings had all classes exported on frame two. There were no references to the object until frame two.

Then, flash crashed whenever I compiled without the "Export in frame one" box checked.

To fix this, a friend suggested I start my game logic on frame 3, so it will have properly loaded frame 2. That seemed to work fine, the class was instantiating properly.

Then, it turned out that it was not loading the movieclip, only instantiating the class. Again, this could be fixed by exporting in frame 1, but I really cannot afford to do that.

The same friend suggested I place an instance of the symbol on the stage on frame 3, and perform game logic on frame 4. They said this would initialize the movieclip properly.

However, this was not the case. How can I load the entire symbol, graphics and all, without exporting to frame 1? This single symbol will contain probably 10-20 MB of graphics, so it needs to be preloaded.

Thanks for the help!

EDIT: To make a long story short, all I need is some way to load a movieclip so it can be used and visible and everything.

EDIT: Is there any way to force-load a movieclip via AS3?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恋你朝朝暮暮 2024-08-28 05:09:07

从描述中很难弄清楚。

如果您制作新的 .fla 文件,请将大(10-20MB)剪辑粘贴到第 2 帧上,
将导出帧设置为 2,然后尝试从帧 1 预加载并访问帧 2 中的大剪辑内容,您是否遇到相同的错误?

都有此内容

stop();
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);

function onComplete(event:Event):void{
gotoAndStop(2);
}

假设您在第 1 帧和第 2 帧中

trace(myLargeClip);//where myLargeClip would be your 10-20MB clip

:应该没问题,否则,如果跟踪大剪辑返回 null,您可能需要尝试使舞台无效:

在第 2 帧上:

stage.addEventListener(Event.RENDER,onRender);
stage.invalidate();

function onRender(event:Event):void{
trace(myLargeClip);
}

基本上我的建议是:

  1. 隔离问题。看看您的大剪辑是否在类似但简化的场景中引起问题以及原因,然后一旦您得到修复,请在您的主 fla 中使用它。
  2. 不过,请尝试阶段失效,因为我不完全理解您的设置,所以这只是一个疯狂的猜测。

哈特哈,
乔治

Hard to figure out from descriptions.

If you make a new .fla file, paste your large(10-20MB) clip on frame 2,
set your export frame as 2, then try to preload from frame 1 and access the large clip's content in frame 2, do you get the same error ?

say you have this in frame 1:

stop();
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);

function onComplete(event:Event):void{
gotoAndStop(2);
}

and in frame 2:

trace(myLargeClip);//where myLargeClip would be your 10-20MB clip

It should be ok, otherwise, in case tracing your large clip returns null, you might want to try to invalidate the stage:

on frame 2:

stage.addEventListener(Event.RENDER,onRender);
stage.invalidate();

function onRender(event:Event):void{
trace(myLargeClip);
}

Basically what I'm suggesting is:

  1. Isolate the problem. See if your large clip is causing problems in a similar, but simplified scenario and why, then once you got a fix use it in your main fla.
  2. Try the stage invalidation, although, since I don't fully understand your setup, it's just a wild guess.

HTH,
George

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文