Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Control Spin Wheel Manually

New Here ,
Aug 21, 2021 Aug 21, 2021

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. 

 

 

TOPICS
ActionScript , Code , How to
261
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 21, 2021 Aug 21, 2021

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

...
Translate
Community Expert ,
Aug 21, 2021 Aug 21, 2021

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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 23, 2021 Aug 23, 2021

Thank You so much for the help. It works!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 23, 2021 Aug 23, 2021
LATEST

you're welcome 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines