Ive been using the loader a lot of upload images into my movieclip. But the only way I know how to do it is load the content, add an event listener, wait for it to finish finish the job in the handler using the reference to the loader like this.
protected function loadImage(imageDir:String):void
{
loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT,tilesLoadInit);
loader.load(new URLRequest(imageDir));
}
private function tilesLoadInit e:Event):void {
sprite = Bitmap(loader.content).bitmapData;
//load in xml file for map
xmlToArray();
}
I am trying to be more light with my code. And I would rather call my loader:Loader class locally in the method instead of making a reference in my class. Is there any way to retrieve that loader object in the Event.INIT parameter of my handler?
Same with Sprites in general. Say I create a button. the user clicks on it and it calls the handler. is there anyway I can retrieve that button, remove it from the stage through the Event parameter instead of creating Class references to remove them.
I want to do this to make it easier on garbage collecting. so instead of creating class references of all my objects. I would rather call them locally so when I remove them from the stage, the garbage collector will take care of them.