actionscript 3 - dynamic objects in if condition -


how make if condition contains dynamic object? tried way, error

function pass(xxx:string,yyy:string,zzz:string) {     //trace(xxx,yyy,zzz);     if (this[xxx].hittestobject(this[yyy])) //an original if (obj1.hittestobject(obj2))     {        trace("right");     }     else     {       trace("fail");     } } 

"this[]" not work, typeerror: error #1010: term undefined , has no properties. "this[]" can work if outside "if". there other way problem? before

you should use getchildbyname(), if transferring names of mcs, check if name direct child of this.

function pass(xxx:string,yyy:string,zzz:string):void {     var x=this.getchildbyname(xxx);     if (!x) return;     var y=this.getchildbyname(yyy);     if (!y) return; // insert similar zzz here     if (x.hittestobject(y))     {         trace("right");     }     else     {         trace("fail");     } } 

otherwise specify inputs thje function have.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -