vendredi 30 décembre 2016

Please help how to take instance name wich numbering by array and the number can be operated?

please help me how to solve this i ve been made snake and riddle game in education for assessing student competency

this script for player moving by clicking the button, the array is the place they could be. so the number must be operated

thaks for your help

a.addEventListener(MouseEvent.CLICK,bergerak);
b.addEventListener(MouseEvent.CLICK,bergerak);
c.addEventListener(MouseEvent.CLICK,bergerak);
d.addEventListener(MouseEvent.CLICK,bergerak);


function bergerak (Event:MouseEvent){
        var namatombol:String=Event.currentTarget.name;
        var myarray:Array=[];
                for (var i:int=0;i<3;i++){
                        myarray[i]=this["kotak"+i]; // (i) can be operated like this i+12 then (i) also can merge with string (kotak) in instance name
                        if (namatombol=="a"){
                                MovieClip(root).pemain.x=MovieClip(root).myarray[i].x;
                                MovieClip(root).pemain.y=MovieClip(root).myarray[i].y;
}
}
}

Aucun commentaire:

Enregistrer un commentaire