# Wheel of fortune with powerbar

**URL:** https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464
**Category:** Uncategorized
**Created:** [July 9, 2008, 6:55am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464 "2008-07-09T06:55:06Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![alaric](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@alaric](https://forum.kirupa.com/u/alaric)
#### Post date: [July 9, 2008, 6:55am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/1 "2008-07-09T06:55:06Z")

</div>

Hi all,

I am currently developing a Wheel of fortune game and I am facing the problems in rotating the wheel depending on the power varible. Here power is a varible that depends upon the time for which the user keeps the mouse on the wheel. I am unable to rotate the wheel smoothly. Can anyone help me in this? Any help would be greatly appreciated. Thank you.

---

<div class="post-metadata">

### Author: ![alaric](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@alaric](https://forum.kirupa.com/u/alaric)
#### Post date: [July 10, 2008, 6:34am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/2 "2008-07-10T06:34:33Z")

</div>

glosrfc - did what you said, and posted the codes

function spinWheel(myTarget) {  
wheel\_rotation = 0;  
myRandom = 0;

//Optional allow press of wheel to spin.  
\_root.onEnterFrame = function() {  
myTarget.\_rotation -= wheel\_rotation;  
};  
function slowDown() {  
myTarget.onEnterFrame = function() {  
wheel\_rotation -= \_root.myRandom;  
//trace(\_root.myRandom);  
if (wheel\_rotation\<=0) {  
wheel\_rotation = 0;

}  
};  
};  
speedup = function () {  
myTimer = getTimer();  
myTarget.onEnterFrame = function() {  
wheel\_rotation++;

if (wheel\_rotation\>=10) {  
wheel\_rotation = 10;  
pauseTimer = getTimer();  
timeTrace = pauseTimer-myTimer;  
//trace(timeTrace);  
if (timeTrace\>4000) {  
slowDown();  
}  
}  
};  
};  
}

spinWheel(\_root.wheel);

// button script  
arrow\_btn.onRelease = function() {  
myRandom = Math.random()\*.30;  
if (myRandom\<=.10) {  
myRandom = .10;  
}  
(myRandom);  
speedup();  
};

---

<div class="post-metadata">

### Author: ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)
#### Post date: [July 10, 2008, 10:21am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/3 "2008-07-10T10:21:31Z")

</div>

If you replaced . with an example of the code you’re using, you’re far more likely to get a response.

In the meantime, see if this helps:  
[http://blog.circlecube.com/2008/03/14/interactive-spin-actionscript-tutorial/](http://blog.circlecube.com/2008/03/14/interactive-spin-actionscript-tutorial/)

---

<div class="post-metadata">

### Author: ![alaric](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@alaric](https://forum.kirupa.com/u/alaric)
#### Post date: [July 10, 2008, 3:39pm UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/4 "2008-07-10T15:39:05Z")

</div>

In the meantime, see if this helps:  
[http://blog.circlecube.com/2008/03/1...ript-tutorial/](http://blog.circlecube.com/2008/03/1...ript-tutorial/)

-\> regarding this link, its not totally what i wanted to find, cos its more having like 2 btns, 1 btn for moving clockwise, and the other anti- clockwise. ive tried using both the clockwise but it seems that the codes for clockwise and anti clockwise will clash. And i got another problem is that i need to have an xml which will be used to call pictures and text files onto different sections of the wheel(its like having 12 empty mc and each mc call information from the same xml file) and be able to spin together. any ideas how to do it, cos it seems that i have difficulties inserting the codes for the xml, theres always errors coming up. its like the xml codes and the codes for the wheel to be clashing with each other.

if any doubts can ask again, ill be grateful to reply asap. thanks in advance for any replys to this psot

---

<div class="post-metadata">

### Author: ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)
#### Post date: [July 10, 2008, 4:47pm UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/5 "2008-07-10T16:47:24Z")

</div>

```auto
var maxSpeed:Number = 100;
// fastest possible speed
var maxTime:Number = 10000;
// 10 seconds
function spinWheel(myTarget:MovieClip, clickTime:Number):Void {
	myTarget.speed = clickTime/maxTime*maxSpeed;
	myTarget.onEnterFrame = function():Void {
		slowDown(this, .9);
		this._rotation += this.speed;
	};
}
function slowDown(myTarget:MovieClip, force:Number):Void {
	myTarget.speed *= force;
}
wheel.onPress = function():Void {
	startTime = getTimer();
};
wheel.onRelease = wheel.onReleaseOutside=function ():Void {
	spinWheel(this, getTimer()-startTime);
};

```

?

---

<div class="post-metadata">

### Author: ![alaric](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@alaric](https://forum.kirupa.com/u/alaric)
#### Post date: [July 11, 2008, 1:09am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/6 "2008-07-11T01:09:12Z")

</div>

nice. thanks for the reply. im going to test it out now

---

<div class="post-metadata">

### Author: ![alaric](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@alaric](https://forum.kirupa.com/u/alaric)
#### Post date: [July 11, 2008, 1:45am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/7 "2008-07-11T01:45:02Z")

</div>

oh thats bad, the codes have errors in it. ☹

---

<div class="post-metadata">

### Author: ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)
#### Post date: [July 11, 2008, 2:20am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/8 "2008-07-11T02:20:03Z")

</div>

what are the errors?

---

<div class="post-metadata">

### Author: ![alaric](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@alaric](https://forum.kirupa.com/u/alaric)
#### Post date: [July 11, 2008, 2:36am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/9 "2008-07-11T02:36:20Z")

</div>

**Error** Scene=Scene 1, layer=wheel, frame=1:Line 1: ‘{’ expected  
function spinWheel(myTarget:MovieClip, clickTime:Number):Void {  
**Error** Scene=Scene 1, layer=wheel, frame=1:Line 3: ‘{’ expected  
myTarget.onEnterFrame = function():Void {  
**Error** Scene=Scene 1, layer=wheel, frame=1:Line 5: Unexpected ‘}’ encountered  
this.\_rotation += this.speed; };  
Total ActionScript Errors: 3 Reported Errors: 3

its like simple errors, but it seems i cant solve it, ive checked all the { and } already but theres stil errors. Btw, is it to overwrite all the codes over the codes i have pasted?

---

<div class="post-metadata">

### Author: ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)
#### Post date: [July 11, 2008, 2:48am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/10 "2008-07-11T02:48:19Z")

</div>

what version are you using? :x it should work

---

<div class="post-metadata">

### Author: ![alaric](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@alaric](https://forum.kirupa.com/u/alaric)
#### Post date: [July 11, 2008, 2:49am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/11 "2008-07-11T02:49:34Z")

</div>

im using AS2 ;X is it suppose to work for AS3?

---

<div class="post-metadata">

### Author: ![alaric](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@alaric](https://forum.kirupa.com/u/alaric)
#### Post date: [July 11, 2008, 2:53am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/12 "2008-07-11T02:53:39Z")

</div>

Btw, the codes u haven given me, i have a button that is clickable. When the button is clicked, the wheel will spin.

---

<div class="post-metadata">

### Author: ![alaric](https://avatars.discourse-cdn.com/v4/letter/a/f475e1/32.png) [@alaric](https://forum.kirupa.com/u/alaric)
#### Post date: [July 11, 2008, 3:48am UTC](https://forum.kirupa.com/t/wheel-of-fortune-with-powerbar/265464/13 "2008-07-11T03:48:30Z")

</div>

anyone able to help?
