PDA

View Full Version : Removing Multiple Movie Clips



NeoDreamer
July 11th, 2003, 10:13 PM
I am going to use the removeMovieClip("SomeMovie"); command. Is it possible to close multiple movie clips using only one of "removeMovieClip"? For example, i want to close movie1, movie2, and movie3.

ahmed
July 11th, 2003, 10:15 PM
try this:
for (i=1; i<4; i++) { clip = this["movie"+i]; removeMovieClip(clip); }

NeoDreamer
July 11th, 2003, 10:19 PM
Well, actually, my movies are not named that simply (movie 1,2,3...). A better example is: service, profile, contact.

claudio
July 11th, 2003, 10:27 PM
You can only use removeMovieClip if the mc was created using attachMovie or duplicateMovieClip. Just in case you dont know...

NeoDreamer
July 11th, 2003, 10:37 PM
Then what do I use for regular ones?

claudio
July 11th, 2003, 10:38 PM
unloadMovie or unloadMovieNum

NeoDreamer
July 11th, 2003, 10:40 PM
how do I close multiple movie clips with just using one line of code so that I don't waste time writing so much code?

claudio
July 11th, 2003, 10:41 PM
You want to unload them on a button event?
Are the mcs loaded into level or target?

NeoDreamer
July 11th, 2003, 10:51 PM
on release

claudio
July 11th, 2003, 10:55 PM
Are the mcs loaded into level?

NeoDreamer
July 11th, 2003, 10:56 PM
they are on the same level as the button that wants to close them

claudio
July 11th, 2003, 10:56 PM
If so, try this:max = 2;//im assuming you want to unload mcs on levels 1 and 2
unload = function(){
for (i=1; i<=max; i++) {
unloadMovieNum(i);
};
}
button.onPress = unload;

kode
July 12th, 2003, 01:35 AM
var movies = [service, profile, contact], index;
myButton.onRelease = function() {
for (index=0; index<movies.length; index++) {
movies[index].swapDepths(1000+index);
movies[index].removeMovieClip();
}
};
the removeMovieClip method only works if the MovieClip depth is equal or greater than 0.

NeoDreamer
July 12th, 2003, 01:41 AM
where do you put this code?

kode
July 12th, 2003, 01:43 AM
you put the code on the Frame actions. where myButton is the instance name of the Button that should remove those MovieClips.

claudio
July 12th, 2003, 01:49 AM
I didnt know you could swap depths to remove the mcs.... :!:
thx again kax :)

NeoDreamer
July 12th, 2003, 01:50 AM
This code broke the rollovers I had on my button. They don't show anymore. And also, I didn't want the movie clips to disapear forever. They should be able to come back when an action loads them again.


Why?

I am making a navigation system. Each section is a different movie clip symbol. When the user wants to go to another section, the current section must be removed. But, the removed section should only be temporary, as people might want to go back.

claudio
July 12th, 2003, 01:52 AM
Usemoviclip._visible = false;

kode
July 12th, 2003, 01:52 AM
- claudio

no problem. ;)
and actually, you shouldn't thank me... i learned that from senocular. :P


- Supree

if you need to load them again, you should use the attachMovie method to load them from the Library whenever you need those MovieClips. =)

kode
July 12th, 2003, 01:54 AM
or you could listen to claudio. ;)

NeoDreamer
July 12th, 2003, 02:01 AM
man, that didn't work at all.



on (release) {
awards2._visible=false;
conditions2._visible=false;
help2._visible=false;
thanks2._visible=false;
tutorials2._visible=false;
updates2._visible=false;
}


This is what happened: When clicked on, the new sections would appear under the current section. The current section would stay.

NeoDreamer
July 12th, 2003, 02:07 AM
Oh, brother. Flash should have a simple unload movie clip action!!!!!!

claudio
July 12th, 2003, 02:09 AM
Your code should work.
Are those mcs loaded into an empty mc?

NeoDreamer
July 12th, 2003, 02:14 AM
source file is too large to attach. i am attaching the swf instead. this is without any tampering with the code. when the code is tampered with, (read above).

claudio
July 12th, 2003, 02:24 AM
Ok, whats the action of the close button on the windows?

NeoDreamer
July 12th, 2003, 02:31 AM
code for the [ x ] button on the sections

[/code]
on (rollOver) {
tellTarget ("/awards2/exit") {
gotoAndPlay("rollover");
}
}

on (rollOut) {
tellTarget ("/awards2/exit") {
gotoAndPlay("rollout");
}
}

on (release) {
tellTarget ("/awards2") {
gotoAndPlay("leave");
}
}
[/code]

This is for the awards section. "awards2" is the instance name of the movie clip that has the section window. "awards" is the instance name of the movie clip that has the awards button symbol.

claudio
July 12th, 2003, 02:37 AM
Why dont you tell the current mc to go to its exit frame when a new movie is loaded.

NeoDreamer
July 12th, 2003, 02:38 AM
How do you call up the current MC? What is its name??? Flash will have a hard time telling which MC is the window MC, because there are many other MCs running simultaneously as special effects.

claudio
July 12th, 2003, 02:41 AM
Id use a variable to control which movie clip is currently being displayed and when another button is clicked, the current mc goes to its exit frame.
Does it makes sense to you?
:-\

NeoDreamer
July 12th, 2003, 02:42 AM
Yeah, I know the concept, but I do not know anything about actionscript.

claudio
July 12th, 2003, 02:51 AM
Hmm lemme thin a better way

radicaljugnu
July 12th, 2003, 03:12 AM
why don't u create an array of the swf files and then use a for loop and removeMovieClip(array[i]) or something lik that

Coppertop
July 12th, 2003, 10:12 AM
or, if the thing thats closing all the movie clips is a button, why the hell don't you just put:

on (release) {
removeMovieClip("service");
removeMovieClip("profile");
removeMovieClip("contact");
}

really easy, really simple, no problem. and if that doesn't work, then add the path to them as well like "_root.service" or "_root.someothercrazymc.service"

simple ways are nice too ya know

NeoDreamer
July 12th, 2003, 01:23 PM
That don't work, coppertop. Look at the attachment. I have an MC named "mc" and a button that has your code.

NeoDreamer
July 12th, 2003, 01:24 PM
Originally posted by kartik
why don't u create an array of the swf files and then use a for loop and removeMovieClip(array[i]) or something lik that

Because I know nothing about actionscript

kode
July 12th, 2003, 01:29 PM
Originally posted by kax
the removeMovieClip method only works if the MovieClip depth is equal or greater than 0.

on (release) {
mc.swapDepths(1000);
removeMovieClip(mc);
}
:sigh:

NeoDreamer
July 12th, 2003, 01:33 PM
Now, it can never be loaded up again... See attachment.

kode
July 12th, 2003, 01:45 PM
Originally posted by kax
if you need to load them again, you should use the attachMovie method to load them from the Library whenever you need those MovieClips.

NeoDreamer
July 12th, 2003, 04:29 PM
I solved the problem. I just told all the sections to goto and play a blank frame.