With this kind charge content (image or swf). It also illustrates the use of listeners.
package {/ / import classes import
flash. display .*;
import flash.events .*;
flash.net.URLRequest import;
cargaImagen
public class extends Sprite {Constructor
//_________ cargaImagen public function (): void {
/ /}
//____________
to start charging method
public function init (image: String): void {
/ / Create loader object
var loader: Loader = new Loader ;
/ / listeners are added
ponListeners (loader.contentLoaderInfo)
/ / I think the object containing the request
var request: URLRequest = new URLRequest (image);
/ / Position
loader.load request (request );}
/ / Add listeners to the charger
ponListeners function (dispatcher: IEventDispatcher): void {
dispatcher.addEventListener (Event.COMPLETE, completeHandler)
dispatcher.addEventListener (HTTPStatusEvent.HTTP_STATUS, httpStatusHandler)
dispatcher.addEventListener (Event.INIT, initHandler)
dispatcher.addEventListener (IOErrorEvent.IO_ERROR, ioErrorHandler)
dispatcher.addEventListener (Event.OPEN, openHandler)
dispatcher.addEventListener (ProgressEvent.PROGRESS, progressHandler)
} / / function to execute when it finishes.
completeHandler function (event: Event): void {
trace ("completeHandler:" + event);
addChild (event.target.content)
} / / It runs on receipt of an HTTP status code httpStatusHandler
function (event: HTTPStatusEvent): void {
trace ("httpStatusHandler:" + event);}
/ / Dispatched when the object's properties loaded are available
/ / Since the distribution could change the object (width, scale, etc)
initHandler function (event: Event): void {
trace ("initHandler:" + event);}
/ / It runs when an error input / output, for example, when trying to load a
/ / nonexistent file
ioErrorHandler function (event: IOErrorEvent): void {
trace ("ioErrorHandler:" + event);}
/ / Executes when the loading begins
openHandler function (event: Event): void {
trace (" openHandler: "+ event);}
/ / is executed during the loading progress
progressHandler function (event: ProgressEvent): void {
trace (" progressHandler: bytesLoaded = "+ event.bytesLoaded +" bytesTotal = " + event.bytesTotal)
}}}
0 comments:
Post a Comment