Ok I don’t know how to put this; I’m sorry if the title is confusing.
it might be a very stupid question, and maybe it has been answered before, but I have no idea what to search for.
Here’s my problem: I have a class (called “Page”), that contains a loader that loads data off a php script. now I have an event launched when the loader finishes loading, and that populates some variables.
Here’s my problem: I want to create an empty function within the class that is also launched when the loader finishes loading. In fact, I have text boxes in the flash file that I want automatically populated upon loading.
to sum it up, I would have a class file Page.as:
package{
import blah
public class Page{
private var currRequest:URLRequest = new URLRequest();
private var currLoader:URLLoader = new URLLoader();
public function Page(){
currLoader.addEventListener(Event.COMPLETE, completeHandler);try{
currLoader.load(currRequest)
}
catch(error:Error){trace("Unable to load URL");}
}//end of constructor method
public function onLoad(){};
private function completeHandler(event:Event):void{
onLoad()
}
}
}
yeah i know there is lot of stuff missing, I’m just putting the essential so you get the idea.
And in my flash file:
var tempPage:Page = new Page();
tempPage.onLoad = function(){/**function goes here**/}
Now, I tried to declare the public function in many places, but it never works.
How can I have a custom function that is launched when the loader has loaded?
I tried putting a boolean in my class called isLoaded and check on it with a timer from my flash file, but I’m sure there should be a more elegant way to do it.
Thanks in advance