A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: rotation one click at a time

  1. #1
    Junior Member
    Join Date
    Jun 2017
    Posts
    2

    rotation one click at a time

    Good afternoon,

    I am trying to rotate an object, but it only rotates a little bit with every mouse click. I would like the rotation to be continuous while I drag the mouse until I reach the desire position. I tried to use mouse_move event, but it will not allow me to grab the elements as they keep moving.
    I am new using as3 any help is appreciated. This is what I am trying to use:

    var rotationSpeed:int = 0;
    var rotationValue:int = 0;

    stage.addEventListener(MouseEvent.CLICK, clickStage);
    function clickStage(event:MouseEvent):void
    {
    event.target.rotation +=10;
    }

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    This is a start. It still needs some work. Basically this will function like a switch. If isRotating is true then it will rotate the object. You just need to figure out when to change the isRotating state. My suggestion would be to just do it while the mouse is down. https://stackoverflow.com/questions/...-in-subclasses has some good code dealing with that.
    Code:
    var rotationSpeed:int = 10;
    var isRotating:Boolean = false;
    
    stage.addEventListener(MouseEvent.CLICK, clickStage);
    function clickStage(event:MouseEvent):void
    {
    }
    addEventListener(Event.ENTER_FRAME, onEnter);
    function onEnter(e:Event):void {
    if(isRotating){
    event.target.rotation +=rotationSpeed;
    }
    }
    .

  3. #3
    Junior Member
    Join Date
    Jun 2017
    Posts
    2

    Thumbs up

    Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center