Thursday, July 12, 2007

Preload into a container (MovieClipLoader)

// start listener for preloader
var loader:MovieClipLoader = new MovieClipLoader();

// define what should happen when the image is completely loaded
function onLoadInit(_mc:MovieClip) {
trace("do something"); // this is what will happen once loaded

// this defines what happens while images are loading
function onLoadProgress(_mc:MovieClip, loaded:Number, total:Number) {
myText_txt.text = Math.floor(loaded / total * 100) + "%"; // this shows how much has loaded in a textfield (myText_txt)
// you could also have a bar animate or whatever you want

// start loading the swf/jpg/png whatever
loader.loadClip("myMovie.swf", container_mc); // what you're loading, where you loading to

No comments: