I dont know how advanced or newbie is this, so i am asking here
I want a movieClip to have a Array of other movieClips and hitTest all of them each frame,and if hits run a function callad onHit+nameOfClipHited
I also wanted, for example, inside the array the names are "dog", "cat", but when call a function it would be like "onHitDog" "onHitCat" , i mean, with uppercase
This seems so simple and i cant figure it how to do it
the code:
PHP Code:
var clipsToHitTest:Array;
clipsToHitTest[3] = "dog";
clipsToHitTest[2] = "cat";
clipsToHitTest[1] = "mouse";
clipsToHitTest[0] = "keyboard";
this.onEnterFrame = function(){
var cth = clipsToHitTest[3];
//trace( cth);
if ( this.hitTest( this._parent[cth]) ) {
var nae:String = clipsToHitTest[3];
var firstLetter:String = nae.charAt(0);
var firstLetterUp:String = firstLetter.toUpperCase();
var lastChar:Number = nae.length;
var mySubstring:String = nae.substring(2,lastChar);
var allth:String =firstLetterUp + mySubstring;
var nameFunc:String ="onHit" + allth;
trace(nameFunc);
this[nameFunc];
}
}