I have a map that my client wants their locations(21) to glow in a random order. How I have the flash set up now is the map graphic on one layer and 21 instances of a movie. Being new to action script and coding for that matter I have no clue how to have these movies play one at a time in a random order until all are played then start over in a random order. Is this possible? Thanks a bunch for yoru help. Chris Goodiel
yes. give each of your 21 movieclips an instance name and list them in an array: yourMCA=[mc1,mc2,...,mc21]; use an array shuffle to randomize these movieclips and then start playing the first using a loop to check when it's done playing and start the next. below is an array shuffle method: Array.prototype.shuffle = function() { for (var ivar = this.length-1; ivar>=0; ivar--) { var p = random(ivar); var t = this[ivar]; this[ivar] = this[p]; this[p] = t; } };
I have various movies, all separate swf's. Can you help me to play all of them in one container one after the other, making sure they all finish before next one loads. Would desparately appreciate help. alex
list your swfs in an array, shuffle the array and load them sequentially: Array.prototype.shuffle = function() { for (var ivar = this.length-1; ivar>=0; ivar--) { var p = random(ivar); var t = this[ivar]; this[ivar] = this[p]; this[p] = t; } }; swfA=["swf1.swf","swf2.swf",...,"lastswf.swf"]; // <- customize to match your swf names. nothing else needs editing. lo=new Object(); lo.onLoadInit=function(targ){ targ.onEnterFrame(){ if(this._currentframe==this._totalframes){ index++; if(index<swfA.length){ mcl.loadClip(swfA[index],targ); } else { delete this.onEnterFrame; // they've all loaded. reset index to zero and use mcl.loadClip(swfA[index].targ) if you want to restart. // call swfA.shuffle() if you want to re-randomize your swfA(). } } } } swfA.shuffle(); index=0; mcl=new MovieClipLoader(); mcl.addListener(lo); mcl.loadClip(swfA[index],targ);
kglad, I took off shuffle, is attached correct and put code in empty fla movie. Getting Syntax error on line 15 ---targ.onEnterFrame(){ Opens to empty screen. Also, to have this loop continuously until exited, how do I do that? Please help again. I would so appreciate your help. Alex //Array.prototype.shuffle = function() { Array.prototype = function() { for (var ivar = this.length-1; ivar>=0; ivar--) { var p = random(ivar); var t = this[ivar]; this[ivar] = this[p]; this[p] = t; } }; swfA=["slide1.swf","slide2.swf","slide3.swf","slide4","slide5.swf"]; // <- customize to match your swf names. nothing else needs editing. lo=new Object(); lo.onLoadInit=function(targ){ targ.onEnterFrame(){ if(this._currentframe==this._totalframes){ index++; if(index<swfA.length){ mcl.loadClip(swfA[index],targ); } else { delete this.onEnterFrame; // they've all loaded. reset index to zero and use mcl.loadClip(swfA[index].targ) if you want to restart. // call swfA.shuffle() if you want to re-randomize your swfA(). } } } } //swfA.shuffle(); swfA(); index=0; mcl=new MovieClipLoader(); mcl.addListener(lo); mcl.loadClip(swfA[index],targ);
I am actually trying to do the same thing only I'm not using imported swf files i just want to attach the movie clips. Would i use this same code? i really have no idea as to how to actionscript. I also don't need it to be continuous. I just need for it to play through the movie clips once and stop.
michelle, you can use the following. be sure you use your linkage ids in the mcA() array. (ie, right click on your library movieclips, click linkage, tick export for actionscript, enter an id name in the box -and in the array- and click ok.) mcA = ["mc1ID", "mc2ID", "mc3ID"]; index = 0; this.attachMovie(mcA[index], "mc", 1); mc.onEnterFrame = function() { trace(this._currentframe); if (this._currentframe == this._totalframes) { index++; if (index<mcA.length) { _parent.attachMovie(mcA[index], "mc", 1); } else { this.removeMovieClip(); } } };
i see a white rotating box, another white one, then a red. post a link to your file. use an empty movieclip to more easily postion your loaded swf. and yes, you can put fscommands in your onLoadInit() handler or you can put it in your external swfs.
I'll have to play with it tonight and let you know tomorrow. The actual slides are to big to post on web. Thank you so much for help so far.
I tried some more, but still only get one slide to load. Put up the sample file again at: ftp://MAImisc.mai-stl.com:plum@ftp.business.earthlink.net Can you please look at files and let me know what I am doing wrong. Thanks, Alex
I have publish for flash 8 and actionscript2 Any other thoughts? I'm on laptop now, so diff computer and works on neither. Thanks,
It fails to load in flash test environment and browser, both. Maybe I still have something set wrong???? If it works for you, does not make sense. I have to get this figured out. Thanks,
for reference, I am on windows xp flash version 8 in flash selected: version = 8 load = bottom up actionscript2 compress movie container will be exe and run movies from there, but tried in html and exe and swf, only first movie loads
Yes, that's it. It works. I owe you big time. Thanks kglad,
kglad, One other thing, sorry. How do I keep it on a continous loop instead of going blank when done?
Don't see what you're looking for? Try a search.
|