开发者

Flash - Adding movieclip into loader

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.contentLoader开发者_如何学CInfo.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


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜