-
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;
}
-
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;
}
}
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|