天天看點

LoaderMax

import com.greensock.*; 
import com.greensock.loading.*; 
import com.greensock.events.LoaderEvent; 
import com.greensock.loading.display.*; 
  
//create a LoaderMax named "mainQueue" and set up onProgress, onComplete and onError listeners 
var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler}); 
  
//append several loaders 
queue.append( new XMLLoader("xml/data.xml", {name:"xmlDoc"}) ); 
queue.append( new ImageLoader("img/photo1.jpg", {name:"photo1", estimatedBytes:2400, container:this, alpha:0, width:250, height:150, scaleMode:"proportionalInside"}) ); 
queue.append( new SWFLoader("swf/child.swf", {name:"childClip", estimatedBytes:3000, container:this, x:250, autoPlay:false}) ); 
queue.append( new MP3Loader("mp3/audio.mp3", {name:"audio", repeat:2, autoPlay:true}) ); 
  
//prioritize the loader named "photo1" 
LoaderMax.prioritize("photo1");  //same as LoaderMax.getLoader("photo1").prioritize(); 
  
//start loading 
queue.load(); 
  
function progressHandler(event:LoaderEvent):void { 
    trace("progress: " + event.target.progress); 
} 
  
function completeHandler(event:LoaderEvent):void { 
    var image:ContentDisplay = LoaderMax.getContent("photo1"); 
    TweenLite.to(image, 1, {alpha:1, y:100}); 
    trace(event.target + " is complete!"); 
} 
  
function errorHandler(event:LoaderEvent):void { 
    trace("error occured with " + event.target + ": " + event.text); 
}