-
[F8] simple question..
Hey everybody,
Ok, i'm wondering if I can simplify and shorten my code.
Currently, I have:
Code:
mc1.play();
mc2.play();
mc3.play();
mc4.play();
mc5.play();
is there any way to simplify this by doing something along the lines of
Code:
mc1,mc2,mc3,mc4,mc5.play();
I know this doesn't work, but i was wondering if there is a way to take tell multiple things to do the same action without having to write the command for each one seperately, or do an array or anything like that.
-
FK'n_dog
for(var n=1; n!=6;n++){
this["mc"+n].play();
}
-
Hey you rock man, thx for helpin us all out here.
That works, but it would only work for examples where all the movieclips are actually named like that.
What if you want to click a button to stop multiple movieclips on the stage, but the names are not incremental like that? Would you have to type myMovie.stop(); for every movieclip or can you write one line of code that will stop multiple movies if they're names are totally different?
-
All 1s and 0s
Hi,
Write a function to stop movies passed as the arguments.
code:
function stopMovies() {
for (var i in arguments) {
arguments[i].stop();
}
}
stopMovies(movie1, anotherMovie, mov3);
Hope this helps.
"If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton
-
Flashmatics
and if u want to stop loads of movie clips but not write out their names then do:
Code:
stopAllMovies(_root);
function stopAllMovies(movie:MovieClip):Void {
movie.stop();
for (var i:String in movie) {
if (movie[i] instanceof MovieClip) {
movie[i].stop();
stopAllMovies(movie[i]);
}
}
}
the above example will stop all movieclips in the _root timeline (change this timeline according to your needs)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|