/    Sign up×
Community /Pin to ProfileBookmark

I need help with a script please!

x = Math.ceil(Math.random()*9);
gotoAndplay(x);

This is a script I got for a flash project! what it does is randomly go to a frame!
9 is the number of frames but I want it to not rely on the number 9 I want it to just go random from frame to frame and only the frames that are filled no number needed(not blank frames only the ones I got artwork on!)So every time I add a new frame I haven’t got to modify the number *9 to ten or 11
in the end if i have a thousand frames when I add frame 1001 I haven’t got to modify 1001 frames!please help that is too many frames to be modifying action script!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinJul 14.2007 — wrong forum!

but:

you need to define an array and put into it the values of the frames of your artwork.

now lets say your array has 10 items, you call the random number getter with the number 9, like you do, and that is the number of the element in the array that you select the frame number from.

something like:

[B]var myFrames = array(0, 3, 7, 12, 15, 22, 34, 36, 45, 55);

x = Math.ceil(Math.random()*9);

gotoAndplay(myFrames[x]);[/B]


maybe not quite right as I cannot remember how you define an array in actionscript, but that should work.
Copy linkTweet thisAlerts:
@Mr_JJul 14.2007 — Give this a try

x = Math.floor(Math.random()*parent.frames.length);

gotoAndplay(x);
Copy linkTweet thisAlerts:
@damienlbauthorJul 16.2007 — The code didn't seem to work for what i need. I really appreciate the free script help! let me explain a different and more detailed way I found to approach this. I need to show swf's I have in a folder on my server at random I mean when they refresh it will be a different swf every time and these swf's finish and move on to the next in a random looping manor kind of like a text ad pay per click type stuff but with flash and im using flash movies. so lets say i want some one to paste a script on their site that brings up my flash file...it will rotate the swfs i have in my folder on my server in their site ..that way i can update it when necessary and if i want to add more movies I wont have to fix the code every time.sorry if that is too much to ask I wouldnt know if it is a simple code or not.so all in all if i add another movie to the folder containing all of the swf's it will randomly be generated on any site my script is on.please help if you can!
Copy linkTweet thisAlerts:
@Mr_JJul 16.2007 — Your probably best going with PHP, I would ask in that forum
×

Success!

Help @damienlb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...