if i wanted to have a function that returned a random number in flash mx, would it generate a new random number each time its called, each time the frame is entered or only once ever?
in php in generates a new random number each time the function is called but that doesnt seem to be happening here.
function headshake() {
A = math.floor(math.random() * 1000)
return A
}
is approximately what i had. is there something wrong with that? it should generate a number everytime it gets that frame (because each time it calls the function again.)
the function is defined in a movie clip in a movie clip, and i call it in the same frame that its defined in (more than once). should i just define it in teh main timeline and see what happens?
To make sure you get different number everytime, use time object to generate random number. I used to use it all the time when I code in java. time is good because it’s always changing.
Karzchix is 100% right on that. The time object is nice for that.
I would define the function in the _root timeline and then call out to it by a call to _root.headShake();, yes. I’m not sure if that is causing your problem or not… but it’s easier to figure out what’s going wrong if you don’t have a lot of path issues to deal with.