Skip to main content
March 1, 2011
Question

Spinning a wheel, randomly stops and then takes you to another frame.

  • March 1, 2011
  • 2 replies
  • 2160 views

I would like to be able to spin a wheel in flash, this wheel has 8 sections to it split up equally, it spins for a random amount of time, 3 - 7 seconds and then stops. the section which lands on the marker is the result and will take you to a specific frame. Also i would like it when it stops to gradually slow down however this is not vital.

this code works for just rotating a wheel but i want to know how to randomly stop it and how to take it to another frame.

onClipEvent (enterFrame){
this.ang=ang+0.01;
_alpha=190*Math.sin(this.ang)+190;
_rotation++;
_xscale=260*Math.sin(this.ang)+1900;
}

i do not know a lot of coding, so do not use complicated words and if you could post how to do this it would help alot.

thanks

This topic has been closed for replies.

2 replies

March 5, 2011

can any1 help?

kglad
Community Expert
Community Expert
March 5, 2011

what frame in what movieclip?

March 6, 2011

well at the moment there is just one frame with 2 objects, a button and a wheel. when you click the button it tells the wheel to spin.

kglad
Community Expert
Community Expert
March 2, 2011

you shouldn't attach code to objects.   remove that code.  assign your wheel an instance name, eg wheel_mc.  you can then use:

import mx.transitions.Tween;
var obj:Object = {};
obj.x = wheel_mc._rotation;
var myTween:Tween = new Tween(obj, "x", mx.transitions.easing.Strong.easeInOut,0, Math.random()*360*5, 3+Math.floor(Math.random()*5), true);

myTween.onMotionChanged = function() {
    wheel_mc._rotation = obj.x
};

March 2, 2011

so how you told me to do it works fine i had to look up stuff by myself but thats because i have only started. the other thing i would like to do now is add a button to start the wheel spinning.

so i have this which i dunno if its right or not:

on(press)

{

wheel_mc.start();

}

this is on a instance of the button, which is on a different layer to the wheel. the instance of the button is start_mc

however i cant see if this works or not due to the fact the wheel rotation starts straight away, i have tried different things and cant get the button to stop this from happening.

thanks