Hi,
I hava a class structure like this
class B {
var func:Function;
}
class A {
var b:B;
}
class A1 extends A {
function A1() {
super();
b.func = myfunc;
}
function myfunc(var onoff:Boolean) {
}
}
and somewhere an event handler like this
function hndl(e:Event):void {
if(e.target is A && A(e.target).b.func != null)
A(e.target).b.func(something)
}
So if one of the A variants wants to implement the function, it lives in its own namespace. Now, how could I ensure that the compiler checks the argument structure?
Are you talking about method overloading (not supported) or type checking (as3 is still not strong typed)?
As much as you can do to help yourself is expose a public property to check what version you're running. typeof typically will always return object which isn't useful at all.
This post may help with the methods mentioned.
Yes, method overloading (supplying the same function name with an optional number of arguments) is not supported.
AS3 will get there but for now you're better off doing one of two things.
1, including all possible methods with a default value possible
e.g. private function methodName(a:int = 0; b:String = '', c:CustomClass = CustomClass(), yada...)
2, changing the function name for the arguments you need
e.g. private function methodThatAcceptsFourArguments(a:int = 1, b:int =2, c:int = 3, d:int = 4)
There is nothing in between without method overloading.
Note AS4 has namespaces, overloading, etc....
North America
Europe, Middle East and Africa
Asia Pacific