Flash - 将影片剪辑添加到加载器中

发布于 2024-11-29 22:29:27 字数 893 浏览 1 评论 0原文

我已经为我的 swf 文件创建了一个预加载器。我想在加载另一个 swf 时简单地将图像添加到舞台上。

我的图像保存在库中名为 image 的影片剪辑中。我如何将它添加到舞台上并使其在加载时保持在那里。我尝试过手动将其移动到舞台上,但它只停留一帧。

import flash.display.*;
import flash.events.*;
import flash.text.*;

var myContent:URLRequest = new URLRequest("flashheader.swf");
var myLoader:Loader = new Loader();

myLoader.load(myContent);

myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preLoader);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);


function preLoader(event:ProgressEvent):void 
{    
var loaded:Number = Math.round(event.bytesLoaded);
var total:Number = Math.round(event.bytesTotal);
var percent:Number = loaded/total*100;

 percentText.text = Math.round(percent) + "%"


}

function loadComplete(event:Event):void
{
   addChild(myLoader);
   removeChild(percentText);

谢谢

DIM3NSION

i have created a preloader for my swf file. I want to simply add an image onto the stage whilst another swf is loading.

My image is saved in a movieclip called image in the library. How would i add it to the stage and make it stay there whilst it is being loaded. I have tried manually moving it onto the stage but it only stays for 1 frame.

import flash.display.*;
import flash.events.*;
import flash.text.*;

var myContent:URLRequest = new URLRequest("flashheader.swf");
var myLoader:Loader = new Loader();

myLoader.load(myContent);

myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preLoader);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);


function preLoader(event:ProgressEvent):void 
{    
var loaded:Number = Math.round(event.bytesLoaded);
var total:Number = Math.round(event.bytesTotal);
var percent:Number = loaded/total*100;

 percentText.text = Math.round(percent) + "%"


}

function loadComplete(event:Event):void
{
   addChild(myLoader);
   removeChild(percentText);

}

Thanks,

DIM3NSION

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

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

发布评论

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

评论(1

梦屿孤独相伴 2024-12-06 22:29:27

它只保留一帧的原因可能是因为舞台(您的主时间轴)上有几个帧,所以它只是一闪而过。

尝试添加 stop();如果这是时间轴上第一帧上的动作脚本,则位于此代码的顶部。

无论如何,您需要放置一个 stop() 以防止阶段自动前进到时间线的下一帧。

看看这是否可以为您解决问题,或者请要求澄清。

编辑:好的,你说它时不时地闪烁,所以你的影片剪辑中100%确定有不止一帧。特别是如果您添加了 stop()。确保所有影片剪辑都具有精确的 1 帧,而不仅仅是舞台,如果这是您拥有的整个代码并且您看到它闪烁(该图像的影片剪辑必须循环或其他),则必须如此。

The reason it stays only for one frame is probably because the stage (your main timeline) has several frames on it, so it just zips by.

Try adding a stop(); at the top of this code if this is actionscript on the first frame on the timeline.

In any case, you need to place a stop() to prevent the stage from automatically progressing to the next frame of the timeline.

See whether this fixes it for you or ask for clarifications please.

Edit: OK, you said it's flashing every now and again, so you have more then 1 frame in one in your movieclips 100% sure. Especially if you added the stop(). Make sure all movieclips have exatcly 1 frame, not just the stage, it has to be that if this is the whole code you have and you see it flashing (the movieclip for that image has to be looping or something).

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