PDA

View Full Version : AS3 _global equivalent



stuluk28
April 2nd, 2008, 12:11 PM
Hey all,

I'm working on a AS3 Debug class, now although I've had some problems (helped in a previous kirupa post) my big concern is how to make the Debug class globally accessible?

In AS2 we had a Debug class which we call the static trace() method in and it declares itself as a _global variable but it seems the _global declaration is depriciated in AS3?

Does anyone know of a better way or alternative way to achieve this? so I can reference the Debug class from any other class or scope in an application.

Ordinathorreur
April 2nd, 2008, 12:45 PM
I'd probably use a singleton class in a case like this; that would make it globally accessible and in this case I suspect you'd only ever want one instance of the class instantiated anyway.

Felixz
April 2nd, 2008, 03:20 PM
package {
public class Debug {
public static function blah();
public static var blahblah;
}
}
Debug.blah();
Debug.blahblah=1;

stuluk28
April 2nd, 2008, 05:37 PM
hey guys, I see.

I was hoping you wouldn't say that, I was working on a singleton class but it was proving a little tricky because I needed it to create a new sprite with a textfields and some graphics when it first instantiates.

I can't seem to get the class to add the sprites to the stage. see
http://www.kirupa.com/forum/showthread.php?t=292898

stuluk28
April 2nd, 2008, 05:44 PM
I have noticed that, "arguments" which are sent in a function call contain more information than just the parameters you are passing to the function. for example I am using the callee property of the arguments object in my existing Debug class.

_instance = new Debug(arguments.callee);

Does anyone know where I can find documentation on all the propeties that are sent as arguments to a function? I can't seem to find any docs at the moment. If I can find a reference to the movieclip that called the function I might be able to access the stage and add my debug class instance to it.