Copy link to clipboard
Copied
Hi, I'm having trouble with Actionscript 3.0. I searched a lot of spin wheel tutorial but mostly spin using motion tween or auto spin and get random results.
I would like to know the code for control the wheel manually. Like when we click the wheel n can move it follow your hand movement.
I attach some example of template from a website.
import flash.events.MouseEvent;
import flash.events.Event;
var startRotation:Number;
wheel.addEventListener(MouseEvent.MOUSE_DOWN, startSpinF);
wheel.addEventListener(MouseEvent.MOUSE_UP, stopSpinF);
function startSpinF(e: MouseEvent): void {
startRotation = Math.atan2(e.stageY - wheel.y, e.stageX - wheel.x)-Math.PI*wheel.rotation/180;
this.addEventListener(Event.ENTER_FRAME, spinF);
}
function stopSpinF(e: MouseEvent): void {
this.removeEventListener(Event.ENTER_FRAME, spinF);
}
function spinF(e:Eve
Copy link to clipboard
Copied
import flash.events.MouseEvent;
import flash.events.Event;
var startRotation:Number;
wheel.addEventListener(MouseEvent.MOUSE_DOWN, startSpinF);
wheel.addEventListener(MouseEvent.MOUSE_UP, stopSpinF);
function startSpinF(e: MouseEvent): void {
startRotation = Math.atan2(e.stageY - wheel.y, e.stageX - wheel.x)-Math.PI*wheel.rotation/180;
this.addEventListener(Event.ENTER_FRAME, spinF);
}
function stopSpinF(e: MouseEvent): void {
this.removeEventListener(Event.ENTER_FRAME, spinF);
}
function spinF(e:Event):void{
wheel.rotation = 180*(Math.atan2(mouseY - wheel.y, mouseX - wheel.x)-startRotation)/Math.PI;
}
Copy link to clipboard
Copied
Thank You so much for the help. It works!
Copy link to clipboard
Copied
you're welcome
Find more inspiration, events, and resources on the new Adobe Community
Explore Now