This content has been marked as final. Show 8 replies
Hi Graham Howe
var num = Math.round((Math.random() * 2) + 1);
var movie = eval("movie"+num);
Thanks for the help. I've given it a go, and the movie clips won't move but thats because I've got a stop(); on the first frame inside each clip movie1, movie2 ...
This code should be tell either movie 1, 2, or 3 to go to and play frame 2, right?
Yes the code i gave you works to play one of the 3 movies at random.
Depending on what you want to accomplish, you may want to create a function with that code, and call it at the end of each movie, so that another can start.
What are you tracing. that returns a 'undefined' message?
Hi Sketchsta, Thanks again. The undefined thing was a miss spelling in instances. Please take a peek at the .fla I've attached. What I've done is turn the code into a function and have it return from the end of each movie to call the function to play the next movie. What is not happening is yes, the undefined thing is there again and ends the whole sequence of movies playing. Fairy1, and then Fairy2 plays but then it says undefined and it stops.
I've checked that all of the instances are spelt correctly, and the code is calling the movies labels ok... it's just one fairy fails to play and the whole thing stops.
Thanks for the help
you are tracing the the fairies mc's..you have fairy1, fairy2, fairy3.. your random code wants to play fairy4. You do not have Fairy4, resulting in your undefined message in output panel.
change your multiplier from 3 to 2, as I have stated in the first place.
math.random() returns one of two values. either 0 or 1.
you are multiplying by 3, which would be fine, if you weren't adding 1 to it.
what is happening here, is that Flash is looking for Fairy4 because the random equation is:
(1 * 3) + 1 = 4
Sketchsta, thanking you kindly for your support. My fairies are behaving the way i want them. I may add more for more variations, and now i understand the maths... Should be easy.
Thanking you again
you're welcome, good luck.