Copy link to clipboard
Copied
I've created a custom class that posts to a web page to authorize a user. How can I listen for an event within the custom class?
This is my code within my main class.
var customClass:CustomClass = new CustomClass();
var testingString = customClass.authorize("user@example.com", "password");
the fuction "authorize" within the customClass looks like this:
public function authorize(user:String, password:String):void
{
jSession = new URLVariables();
j_Loader = new URLLoader();
jSession.j_username = user;
jSession.j_password = password;
jSend.method = URLRequestMethod.POST;
jSend.data = jSession
j_Loader.load(jSend)
}
How can I fire an event within my main class once the j_Loader triggers Event.COMPLETE?
You can fire an event using the dispatchEvent() function.
In your main class you assign a listener for the event the CustomClass dispatches after it exists.
Copy link to clipboard
Copied
You can fire an event using the dispatchEvent() function.
In your main class you assign a listener for the event the CustomClass dispatches after it exists.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now