9 Replies Latest reply on May 8, 2012 10:53 AM by iFlashAppsToo

# Random problem

Hi

My ball turns just once and stops where it began after one circle.Meaning 360 degrees; what if I want it to stop at 275, or 160. Help, suggestions,  will be appreciated. Thank you. I can make it turn as many times I want to, but the ball always end up at the origin of mouvement. Timer ???  And Randomize it ?

• ###### 1. Re: Random problem

not enuff info.

how are you making it turn just once? and by turn, do you mean rotate (like the hands of a clock)?

• ###### 2. Re: Random problem

Yes. I click on a button, and the ball turns a full 360 degrees in a circle. I want it to stop anywhere in the circle randomly. Sorry for the choice of words, I mean rotate along a circonférence.

• ###### 3. Re: Random problem

how does the ball rotate? timeline tween or code?

• ###### 4. Re: Random problem

code. I am thinking of using frames to solve my problem, although it want be as elegant as something happening randomly. I am going to choose 7  situations ( frames )  each with a different currantAngle

currentAngle<-.5;

currentAngle<-.7;

currentAngle<-.9;

currentAngle<-1.5;

-------

--------

and so on. Each click will take me to different frame.The user won't notice a thing hopefully.

• ###### 5. Re: Random problem

var newRotation:Number;

var myTween:Tween

myButton.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent){

newRotation = Math.random() * 360;
myTween = new Tween(myBall, "rotation", Strong.easeOut, myBall.rotation, newRotation, .5, true);
}

• ###### 6. Re: Random problem

Giving me error messages. What did I do wrong? I copied, pasted the script and drew a ball and a button.

Scene 1, Layer 'as3', Frame 1, Line 7 1046: Type was not found or was not a compile-time constant: Tween.

Scene 1, Layer 'as3', Frame 1, Line 9 1180: Call to a possibly undefined method Tween.

Scene 1, Layer 'as3', Frame 1, Line 9 1120: Access of undefined property Strong.

• ###### 7. Re: Random problem

i thought you would know to have this up at the top of your code if you didnt already:

import fl.transitions.Tween;
import fl.transitions.easing.*;

• ###### 8. Re: Random problem

Hi

Thank you for your help, but that was not what I was looking for. I am trying to make a roulette, but the ball stops always at the same place, as you can see below. I will do some fine tuning for the sound later.

http://www.er.uqam.ca/nobel/m340201/test/roulete.html

• ###### 9. Re: Random problem

i cant help unless you show your code and explain the setup. without that we can only guess

whats the code for your button?