I would like to access an ActionScript 3.0 top level function from a class of mine, in which a symbol with the same name (trace) as the top level function is already defined:
class A {
public static function trace():void {
}
trace("Test");
}
I would like to call the global ActionScript trace function with trace("Test"), but this is not possible as another symbol function trace() is defined.
In a case where the external definition which I would like to access would be located in a package (flash.utils or so), I could access that external definition with flash.utils.[definitionName], as I do here with ByteArray:
import flash.utils.*;
class ByteArray {
var data:flash.utils.ByteArray;
}
Is there a similar syntactical expression in ActionScript 3.0 that would allow me to access the trace function in the first example without changing the name of my class method trace?
This is a hypothetical question, please do not consider workarounds. I need to solve the problem exactly as asked above. Thanks in advance!
traceis in thepublicnamespace so it could be reached callingpublic::trace, however here the problem is that you are redefining another public trace, so you can’t call the previous one.What you can do is :
1 – if your method trace have not to be
publicmade itprotected or privateand then you will be able to call the original trace:2 – if you can’t change the signature assign the original trace into a static var/const so you can use it later :