Skip to main content
seand25674806
Participant
March 5, 2017
Question

program a spinning wheel in Animate CC

  • March 5, 2017
  • 3 replies
  • 3855 views

Hi. I'm using Animate CC and AS3 and I want to program a spinning wheel for a desktop game like Wheel of Fortune. I want it to rotate and I'm trying to create a meter to determine the strength of the spinning. The wheel is attached to this post.

This topic has been closed for replies.

3 replies

seand25674806
Participant
March 5, 2017

Have you ever played Wheel of Fortune on the Nintendo Entertainment System (NES)? I've attached the "Spin strength" meter to show you what I'm talking about. I want the meter to go in and out automatically so when the user presses "enter" to stop the meter, it determines the strength of the spinning of the wheel

kglad
Community Expert
Community Expert
March 5, 2017

then use the timer on mousedown to start a loop that increments spin strength.

kglad
Community Expert
Community Expert
March 5, 2017

if a user is dragging and dropping the wheel and that's what determines the strength of spin, you can use something like the following to as a spinamount to be used in colin's code:

var prevT:int

var prevY:int;

spinner.addEventListener(MouseEvent.MOUSE_DOWN,downF);

function downF(e:MouseEvent):void{

startF();

stage.addEventListener(MouseEvent.MOUSE_UP,upF);

}

function upF(e:MouseEvent):void{

stopF();

stage.removeEventListener(MouseEvent.MOUSE_UP,upF);

}

function startF():void{

this.addEventListener(Event.ENTER_FRAME,loopF);

}

function loopF(e:Event):void{

prevT=getTimer();

prevY=mouseY;

}

function stopF():void{

this.removeEventListener(Event.ENTER_FRAME,loopF);

spinamount = (mouseY-prevY)/(getTimer()-prevT);  // you'll probably need some function of this parameter to get it right

addEventListener(Event.ENTER_FRAME, onenterframe);  // then colin's code

}

Participant
August 21, 2021

I want to do some mobile app. Do you know how to control the wheel manually?

 

When we click the wheel n move it manually follow our hand/mouse movement?

 

Colin Holgate
Inspiring
March 5, 2017

I'm not really sure that you asked a question yet.

With a spinning wheel you may well use an enterframe function to update things. When you start spinning the wheel you would change the rotation by a lot, and over time you would rotate by less. The code might look like this (I did test it):

addEventListener(Event.ENTER_FRAME, onenterframe);

var spinamount: Number = 30;

function onenterframe(e: Event) {

  spinner.rotation += spinamount;

  spinamount -= .1;

  if (spinamount < .1) stopspinner();

}

function stopspinner() {

  removeEventListener(Event.ENTER_FRAME, onenterframe);

}

The spinner movieclip will spin quickly, and slow down over time. You could change the spinamount -= .1 part, or the var spinamount: Number = 30;; part to change the range o start speed.