| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
|
Im trying to create a spinner for a game, much like the real spinner for the game Twister. There are 51 numbers on the game spinner. I need the spinner to randomly stop at a number after the spin button has been pressed. Im using an arrow instance as a MC, and i can get it to spin, i just need to know how to get it to randomly stop. Any help would be appreciated. If you would like to view the image, go to http://users.computron.net/scottisdn/images/spinner.png
Note: This is just an image, not the actual movie. |
|
|
|
|
|
#2 |
|
Risu Oyabun!
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
|
Kinda tricky, but easy. Put that thar spinner arrow in a MC and tween it through a complete circle. Put the spinner on the stage, name it spinner (clever, no?). Click on it, add this to the exterior code of the MC...
Code:
onClipEvent(load){
stopframe=1;
stop();
}
onClipEvent(enterFrame) {
if (_currentframe == stopframe)
stop();
}
Code:
on (release) {
spinner.stopframe = random(100);
spinner.gotoAndPlay(1);
}
You could put a tween down of it spinning once completely, then add that to whatever random number is generated for the stopframe variable. This would make it look like the spinner goes around once all the way before stopping. Just make certain to add the frame count of this "animation fluff" to the base calculations above (instead of frame 30 for 30, it could be 130). Hope that is of service to you. Happy coding. |
|
|
|
|
|
|
|
|
#3 |
|
Registered User
|
ok, i did that, but for the MC, i am getting this error:
Scene=GameSpinner, Layer=Arrow, Frame=1: Line 1: Clip events are permitted only for movie clip instances onClipEvent (load) { Scene=GameSpinner, Layer=Arrow, Frame=1: Line 6: Clip events are permitted only for movie clip instances onClipEvent (enterFrame) { I have the spinner saved as an MC, why does it keep givin me this error. |
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
the code goes ON not IN the MC. Right click the MC > Actions.
![]()
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
|
|
#5 |
|
Risu Oyabun!
Join Date: Apr 2001
Location: Houston, Texas
Posts: 1,460
|
Yup, as da man said... I'm kinda new on the onClipEvent thing m'self, having only experimented a little with it. It is a VERY cool feature, though, that can save LOTS of time. I can see many ways to exploit this feature. Learn it! Gawd F5 rocks.
Thanks for the clarification, Jesse. I can be cryptic at times... or just downright odd. |
|
|
|
|
|
#6 |
|
Registered User
|
Thanx 20 Ton Squirrel and Jesse, you were a great help to me. It worked. I found out i was putting the code on the frame with the MC instead of on the MC itself. Thank you very much, my spinner is now finished because of your help.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Augh. Too many ways to skin a cat. (game design q's) | beau | Gaming and Game Development | 0 | 01-14-2005 08:08 PM |
| Swapdepth using txt files and dynamic content for game. | superbnerb | ActionScript 1.0 (and below) | 3 | 09-22-2004 08:27 PM |
| Design Flaw Question or Retarded User Question (thats the real question) | ptk22 | Simple Stuff (Newbies) | 1 | 01-31-2004 06:00 AM |
| Another Game Timer question (MX) | friz2002 | Gaming and Game Development | 13 | 04-17-2003 01:47 AM |
| Game "Time Delay" after question is answered | kunafish | Gaming and Game Development | 1 | 07-29-2002 08:04 PM |