-
Loopable?
Hello all...
This code produces a random clip from an array. I need it to loop every 3 seconds. Is this possible?
__________________________________________________ __________
arr = ["strandA","strandT","strandC","strandG"];
arr.sort(function(){return Math.floor(Math.random()*3)-1});
var clip = arr[0];
this.attachMovie(clip,clip,1,init);
__________________________________________________ ___________
Using Flash MX 2004 V7
Thanks!
-
make use of setInterval -
PHP Code:
TL = this; // reference to main timeline
arr = ["strandA","strandT","strandC","strandG"];
function bio(){
arr.sort(function(){return Math.floor(Math.random()*3)-1});
var clip = arr[0];
TL.attachMovie(clip,clip,1,init);
};
bioInterval = setInterval(bio,3000);
-
Thanks for the reply and the code!!
You've been a tremendous help for a struggling new programmer :^D
-
If you don't see my other reply, thanks for the code, it was a big help.
One more question if you don't mind:
Is there any way to keep the movie clips on the stage? They disappear as soon as the function repeats (after 3 seconds).
-
you must use unique depths to prevent overwriting
PHP Code:
TL = this; // reference to main timeline
arr = ["strandA","strandT","strandC","strandG"];
depth = 100;
function bio(){
arr.sort(function(){return Math.floor(Math.random()*3)-1});
var clip = arr[0];
TL.attachMovie(clip,clip,depth,init);
depth++;
};
bioInterval = setInterval(bio,3000);
ps.. change the coordinates of init or each clip will attach to the same position
-
That makes sense....thanks again!