Hello to everybody in the forum.
I need an urgent help.
I’m trying to build a game, well not really a game but sort of in flash as3.
i’ll briefly explain what the game is all about.
there are two panels. One which holds different shapes(like square,circle etc)
the second one is the play area, where a user can drag an instance of any symbol from the 1st panel and place them in the play area.
- the user should be able to drag as many number of instances they want
- the user should be able to drag the instance around using the mouse and rotate any one of them using the keyboard arrow. (this is another area where i’m stuck, how to controll movieclips that are dyamically created and also how do i use keyboard to control the rotation of a particular clip)
before i build the game, i was trying out some controls on movieclip but i getting some problem.
I have two movieclips on the stage and i’m trying to rotate any one of it using the keyboard arrows but it not working. Here is the script. i have commented where i encounter the problem.
please help
here is the code
//registring the movieclips
mGreen.addEventListener(MouseEvent.CLICK,test);
mBlack.addEventListener(MouseEvent.CLICK,test);
var trackName:String="";
function test(evt:Event):void {
//sending the name of the movieclip to the trackName variable to be controlled using the keyboard
trackName = evt.currentTarget.name;
}
stage.addEventListener(KeyboardEvent.KEY_DOWN,rotate);
function rotate(evt:KeyboardEvent):void {
switch (evt.keyCode) {
case 37 :
// THIS IS WHERE MY PROBLEM . MY TRACE FUNCTION PERFECTLY TRACES THE NAMES OF THE MOVIES CLIPS BUT
//WHEN I ASK IT TO ROTATE,THE WHOLE STAGE ROTATES.
[trackName]rotation+=10;
trace(trackName);
break;
case 38 :
trace("up");
break;
case 39 :
trace("right arrow");
break;
default :
break;
}
}