Groups | Blog | Home
all groups > flash actionscript > august 2004 >

flash actionscript : Random Scene Generator


Nilps
8/15/2004 7:09:24 PM
hi
ive been trying to create a random scene generator. i want to click a button
which will randomly produce scenes that are in the array. i have been trying
the following code and it does not seem to work. if anyone could please tell me
what i am doing wrong. i would really appreciate it. thank you. Nilpa

Jumping to a random label, scene, frame
1. define a label in every frame you want to jump randomly
2. use the following script:

// define a array with all your previously defined labels
labelarray=["scene1","scene2","scene3","scene4"];

// calculate a random index for this array
randomidx = random(labelarray.length);

// jump to the label at the random index
gotoAndPlay(labelarray[randomidx]);

kglad
8/15/2004 10:36:29 PM
Nilps
8/16/2004 3:43:20 PM
hi
thank you for your quick reply. if you could answer one more question for me.
is it possible to move the scenes into individual movies and then create a
random movie generator? if so then what is the best way of doing this.
thank you again
Nilpa
kglad
8/17/2004 2:03:11 AM
sure. you can copy frames from a scene and paste them into a new movie or a
new movieclip. if you pasted into a new movie you would probably want to use
loadMovie() or loadMovieNum() to add this to your _level0 movie and if you
pasted into a movieclip you could use attachMovie() to add your movieclip to
your _level0 movie.

the best way depends upon your needs. the most basic consideration would be
the size of your movies or movieclips and the number of them. you might want
to use movies if the total size of you _level0 movie (if you used movieclips)
would be so large it would significantly slow the loading of your movie. by
using movies the size of you _level0 movie would be reduced and the loading
could be better controlled.
Nilps
8/23/2004 2:58:37 PM
hi
thank you for your help. sorry for late reply. i decided to just copy and
paste the scenes into one then run a random generator that way. seems to work
for a small number in the array.

thanx
nilpa
kglad
8/23/2004 8:18:49 PM
AddThis Social Bookmark Button