Skip to main content
Inspiring
March 3, 2013
Answered

Listening to event within custom class

  • March 3, 2013
  • 1 reply
  • 331 views

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?

This topic has been closed for replies.
Correct answer Ned Murphy

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.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
March 3, 2013

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.