PDA

View Full Version : Event.COMPLETE Help



SumYungGai
January 23rd, 2010, 06:25 PM
I have a source class that gets data through a site and sends it back to the class. It takes a little bit and my main program responds faster than the site does. I got around this problem...kinda, but I'd like to do it an easier way, by using the Event.COMPLETE listener instead of the Event.ENTER_FRAME one.

authUser is in an external class, while checkAuthorized is part of my main program

ActionScript Code:

var trophyAPI:AS3_API = new AS3_API();

trophyAPI.authUser(gameID, privKey, userName, userToken);
trophyAPI.addEventListener(Event.COMPLETE, checkAuthorized);




Something like this, though it says that addEventListener is an undefined method.

authUser takes like, half a second, but it's still taking too long. I was wondering how I could add the Event.COMPLETE to the trophyAPI to make it checkAuthorized when it was done.

Am I going to have to move a bunch of things around?

Shaedo
January 23rd, 2010, 08:19 PM
If you have your 'AS3_API' class extend something that is allowed to have event listeners on it like a Sprite like this:

public class AS3_API extends Sprite
and make sure that what ever class is adding the event listener has access to the various events class by adding this:

import flash.events.*;

then I think you should be ok?

so:
1) find your AS3_API.as file and open it.
2) find the line 'public class AS3_API' and change it to 'public class AS3_API extends EventDispatcher' (or extends Sprite or MovieClip etc)
3) save your file

More information here:

http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/events/EventDispatcher.html

SumYungGai
January 23rd, 2010, 08:23 PM
=) Thanks