|
Don’t know isf this
solves your problem. It isn’t what you
asked for but at least you can skip the compiler error without altering class A
or B or C: (Dynamic setting the
return type to a Number for example isn’t possible in AS2 and probably
neither in AS3, haxe I don’t know) So use a down(?)cast: You specify a return type
C but in fact you return a B instance (that is compatible with C) from A.getObj(); Normally downcasts are not
safe and are not best coding practice, but in this case it might be the
solution. do a downcast like this
should prevent the compiler error: var aObj:A = new A(); trace(B(aObj.getObj()).doB()); good luck, Arnoud Van:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Bjorn Schultheiss I require type checking Eg. A nasty example class A {
function A() {}
function getObj():C {
var bObj:B = new B();
var _aObj:Object = {};
_aObj['b'] = bObj
return _aObj['b'];
} } class B extends C {
function B(){}
function doB():String{
return 'b.done';
} } class C{} //test var aObj:A = new A(); trace(aObj.getObj().doB());
//compiler error of course I don’t want have
to define doB on the C class, but still have compile time type checking if I
call a method that does not exist on B or C From:
[EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ian Thomas Won't a return
type of Object cover whatever you need? On 5/23/06, Bjorn Schultheiss <[EMAIL PROTECTED] >
wrote: Is it possible to dynamically set a method's return type in as2, as3 or
haxe? |
_______________________________________________ osflash mailing list [email protected] http://osflash.org/mailman/listinfo/osflash_osflash.org
