Skip navigation
Currently Being Moderated

How to rotate a square?

Jul 23, 2012 8:33 PM

hello everyone.

 

i am trying to rotate a square. for that i used below code.

 

square.rotation = 90;

 

this is working fine. But it is working just on one single click..once i have clicked on it it'll rotate. but if i click on it second time it is not rotating.

 

so how can i do this. can anyone tell me how to do this???

 
Replies
  • Currently Being Moderated
    Jul 23, 2012 9:16 PM   in reply to sachin_mak

    //do

    //loca is button, loco is movieclip(square)

     

     

    loca.addEventListener(MouseEvent.CLICK, fStart);

    var speed=8;
    function fStart(event:MouseEvent):void {
    loco.rotation+=speed;
    }

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 24, 2012 5:10 AM   in reply to sachin_mak

    The reason it only worked once is because you were assigning it a fixed value unstead of changing the value each time...

     

    square.rotation = 90;

     

    tells its rotation value to be 90 degrees.  After you reach it the first time, it is at 90 degrees all the time after that.  Instead, to have it change by 90 degrees each time... 

     

    square.rotation += 90;

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points