| Welcome to Brackenwood. We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Help with Random Function | |
|---|---|
| Tweet Topic Started: Feb 11 2006, 12:07 PM (163 Views) | |
| Andros | Feb 11 2006, 12:07 PM Post #1 |
|
Check my location.
|
Alright, I figured out that Math.random(); can make a random number between 0 and 1. How can I apply this to make something similar to chluaid's "random sarus word of the day?" In other words, how can I make a random phrase appear each time the thing is loaded? |
![]() |
|
| smoscar_01 | Feb 11 2006, 02:38 PM Post #2 |
|
Mid-Level ActionScripter
|
The easiest way to do that is getting all your messages of the day at a frame of a movieclip named 'theword' and then at the first frame action youll need to add this
|
![]() |
|
| Vector | Feb 11 2006, 03:27 PM Post #3 |
|
Resident Actionscript Guru ♂
![]()
|
don't forget the + 1, smoscar: The random function returns a value from 0 to the max number that you specified, - 1.
Should do the trick. Math.random() was depreciated (is not supposed to be used) since MX I think. |
![]() |
|
| Mr. Jiggmin | Feb 11 2006, 04:26 PM Post #4 |
|
made of tulips
|
I think you've got your randoms confused, Vec.
|
![]() |
|
| Andros | Feb 11 2006, 04:42 PM Post #5 |
|
Check my location.
|
I tried putting that code into the movieclip named "theword," but this pops up when I try it: **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 1: Statement must appear within on/onClipEvent handler theword.gotoAndStop(random(theword._totalframes) + 1); Total ActionScript Errors: 1 Reported Errors: 1 With my limited knowledge, I tried "onClipEvent(enterFrame)." It got rid of the warning, but then it didn't work like it should have. |
![]() |
|
| Mr. Jiggmin | Feb 11 2006, 04:56 PM Post #6 |
|
made of tulips
|
That code needs to go on a keyframe, not a movie clip. Make a new layer, then make a blank keyframe where the movie clip is. With that frame selected, put that code in the code box thingy. If you want to put the code on the movie clip then you'll want something more like this:
|
![]() |
|
| Andros | Feb 11 2006, 05:15 PM Post #7 |
|
Check my location.
|
Awesome. Thanks a million... well, maybe not. Can you break a twenty? |
![]() |
|
| smoscar_01 | Feb 12 2006, 03:59 AM Post #8 |
|
Mid-Level ActionScripter
|
ooh yeah thanks vector hahaha :lol:
?
|
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Actionscript · Next Topic » |







?
5:11 AM Jul 12