You would think that finding documentation on how to preload your flash would be easier. There are lots of 'create your own loading bar' tutorial. But that's not what I was set out to do. I was set out to have the first frame show an animated gif until the other frames were loaded, and then send the viewer on to the next frame when the load was complete.
Here is how you can do this with Adobe Flash CS4, and I assume CS3.
Place this in the fist frame of your 'actions' layer. If you are unfamiliar with what I mean by this, then the actions layer is a layer in the scene that will hold the actionscript for each frame.
---------------------------------------------------------------------
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
//adds listener to the progress of the load, and points to function "onProgress"
// This isn't needed for our tutorial, but it's included for a time when we may want to ad a load indicator.
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);
//adds listener to the completion of the load, and points to function "onComplete"
//This is meeded, it will help us figure out when the load is complete
//function onProgress(e:ProgressEvent):void
//{
// var loaded:Number =e.target.bytesLoaded;
// var total:Number = e.target.bytesTotal;
//var pct:Number = loaded/total;
//loader_mc.scaleX = pxt;
//loaded_txt = "Loading..." + Math.round(pct&100)) + "%";
//}
// none of the above function is needed for this tutorial
function onComplete(e:Event):void
{
gotoAndStop(2);
}
// the above is required. when load complete, we'll be scooted right to the next frame.
---------------------------------------------------------------------
With this in the action frame 1, it sets up your first frame to hold an animated gif, and then after loaded it will shoot you on to frame 2, where your movie begins.
0 replies
Post a Comment
Subscribe to: Post Comments (Atom)