Spinning game wheel
- Started
- Last post
- 12 Responses
- CygnusZero4
So I have to make a game wheel in Flash (yes Flash) where when you click a button, it just spins and stops randomly.
Ive done a bit of googling and Im not finding a whole lot. I found one youtube vid of a really shitty one. Found another where you spin it by dragging the mouse vertically to spin the wheel, which I dont want, and Im not an AS expert so Im trying to find something that doesnt need a lot of modifying to the code.
Can anyone point me in the right direction?
- CygnusZero40
This is the one that requires you to drag. This is AS3 which Im not familiar with at all, so modifying this to be just a mouse click would take me forever to figure out.
- ORAZAL0
If you can't find an example with a button you would have to call the spinWheel function from your button. You would need to remove the extra code and replace line.height by a static value.
It's shouldn't take you that much time. I understand that you rather have something where you don't need to tweak the code.private final function spinWheel():void
{
// speed = line.height * 0.1;
speed = 0.5;
stage.addEventListener(Event.ENT... spin);
}
- CygnusZero40
The problem with that example is I am totally lost with AS3. Like that code you just gave me, I wouldnt have any clue where to put that, or what I would need to modify to get rid of the dragging and replace it with a button.
- I understand, it can quickly get complicated. I'll look for something.ORAZAL
- CygnusZero40
You would think that there would be a lot of examples of something like this in Flash out there but there isnt. I thought I could find something ready to go pretty quickly.
- spot130
This brings me back. Basically you want to set the number of rotations to a random number rounded to the first decibel. Check out this Flash Kit (amazing it's still online) post from the good old days and download 'spinner v3.fla' for an example:
- ORAZAL0
http://b3vad.persiangig.com/Drop…
package {import flash.display.MovieClip;
import flash.events.MouseEvent;public class main extends MovieClip {
public function main() {
addEventListener(MouseEvent.CLIC...
}public function clcks(e:MouseEvent):void {
if (e.target.name == "doit") {
var rr = Math.round(Math.random()*360);
spn.rotation=-rr;
spn.play();
trace(Math.round(rr/22.5));
}
}
}- You would still to set up the clips & code file. I know you're looking for a full .flaORAZAL
- CygnusZero40
Hmmm this spinner 3 file is getting to what I need. The script in it runs immediately though. How do I have it execute when I click a button? And keep in mind this button basically needs to keep working.
So when one person presses it, it needs to spin the wheel and stop randomly, but that button needs to continue doing that without reloading the file. This file is going to be on a TV screen at an event.
- Just add a stop in the timeline and a button that jumps the timeline ahead to the next frame with the movie clipspot13
- CygnusZero40
Hehe, spot, I actually did exactly that, and it works for 1 button press, but cant figure out how to get the button to execute the script a second time.
- Bennn0
thats thread looks like its from 2002 hehe
- I know. This is for an event so Flash still has uses for things like that.CygnusZero4
- Im sure this can be done with JS, but this is getting handed over to a bunch of idiots. Id rather it just be 1 file that runs full screen at launch.CygnusZero4
- it does, I can't remember the last time I used ASdrake-von-drake
- CygnusZero40
Aside from using the timeline to jump around which probably isnt going to work for this, how do you get a button to tell a script to execute in Flash?
This spinner3 script just runs immediately when the playhead is on the script, which is problematic because of the fact that this play button needs to keep working over and over without reloading the Flash.
- spot130
I've added a button and a QBN logo:
http://spot13.com/nt/spinner-qbn…
http://spot13.com/nt/spinner-qbn…- cygnus owes you a beer or 6. nice worklvl_13
- thx manCygnusZero4
- CygnusZero40
Yo Spot! I have an FLA I want to send you, if you dont mind. It's in really good shape, except that the randomness of what the wheel stops on doesnt seem to be quite random enough.
How can I get this file over to you?
- sent - this reminded me of what QBN used to be, and maybe still is - a collaborative community :)spot13