johnlouis
April 13th, 2008, 11:33 PM
i want to make a preloading function that could be used by any Loader object I have regardless of name. I'll explain in code
loader1.contentLoaderInfo.addEventListener(Progres sEvent.PROGRESS, loadProgress);
loader2.contentLoaderInfo.addEventListener(Progres sEvent.PROGRESS, loadProgress);
loader1.contentLoaderInfo.addEventListener(Event.C OMPLETE, loadComplete);
loader2.contentLoaderInfo.addEventListener(Event.C OMPLETE, loadComplete);
function loadProgress(e:Event):void{
//how do i get a reference of the object that is calling this function?
trace(targetObject.bytesLoaded); //i want to reference the contentLoaderInfo of the Loader currently using this method
}
function loadComplete(e:Event):void{
addChild(targetObject.parent); //not sure if that's logical
}
I hope i'm making sense. :book:
loader1.contentLoaderInfo.addEventListener(Progres sEvent.PROGRESS, loadProgress);
loader2.contentLoaderInfo.addEventListener(Progres sEvent.PROGRESS, loadProgress);
loader1.contentLoaderInfo.addEventListener(Event.C OMPLETE, loadComplete);
loader2.contentLoaderInfo.addEventListener(Event.C OMPLETE, loadComplete);
function loadProgress(e:Event):void{
//how do i get a reference of the object that is calling this function?
trace(targetObject.bytesLoaded); //i want to reference the contentLoaderInfo of the Loader currently using this method
}
function loadComplete(e:Event):void{
addChild(targetObject.parent); //not sure if that's logical
}
I hope i'm making sense. :book: