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
Post a Comment