FORUMS: list search recent posts

How do I remove an MC loaded with attachMovie!?!?!?!?

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
lajoiet
How do I remove an MC loaded with attachMovie!?!?!?!?
on Dec 5, 2005 at 3:10:37 am

Why is it the things that seem the simplest never work out the way you thing?

I'm loading a few informational windows above an application I'm developing using some buttons. There are 4 different Info buttons that load 4 different Info Movie Clips using the following code (this is one of the buttons, the other 3 are the same except for the instance names. In this example, the button is called wmfInfo, and when pressed it loads the movied clip called wmfInfoMC and gives it an instance name of infoHolder.)

wmfInfo.onPress = function() {
_root.attachMovie("wmfInfoMC" , "infoHolder" , 1);
}

Now how do I go about unloading the movie clip? I've tried just about everything I can think of. I put a close button with an instance name of closeBtn in the Info Movie Clip (wmfInfoMC in the above example), but I can't get the button to work. The code I've used was basically this:

infoHolder.closeBtn.onPress = function() {
trace("Button Works");
_root.unloadMovie("infoHolder");
}

Instead of "infoHolder.closeBtn.onPress" I have also used "closeBtn.infoHolder.onPress", "wmfInfo.closeBtn.onPress", "closeBtn.wmfInfo.onPress" and any other variations I can think of, and in place of "_root.unloadMovie("infoHolder");" I have used "_parent.unloadMovie("infoHolder");", _root.unloadMovie("wmfInfoMC"); and about 100 other variations, but it doesn't really matter since the trace message never shows up so somehow the code isn't responding to the button.

I'm at my wits end, been fighting with this for over 3 hours now. Any help will be greatly appreciated. Give me your address and I'll fedex my first born.


Return to posts index

Sher Ali
Re: How do I remove an MC loaded with attachMovie!?!?!?!?
on Dec 5, 2005 at 8:16:31 am

The reason is that you are defining the onPress function
for the close button even it is not loaded as you have not
clicked any of your info button.

When you attach movies to any timeline using attachMovie(),
you have to attach the scripts to buttons or movie clips inside
the loaded movie either manually or on the fly when it is loaded.
In this case:

wmfInfo.onPress = function() {

_root.attachMovie("wmfInfoMC" , "infoHolder",1);

infoHolder.closeBtn.onPress = function() {

trace("Button Works");
_root.infoHolder.unloadMovie();

}

}

here are the flas with variations:
http://www.theadsteam.com/sherali/attachMovieFLAs.zip

I hope this helps.


Sher Ali,
Interactive Media Developer


Return to posts index

lajoiet
Re: How do I remove an MC loaded with attachMovie!?!?!?!?
on Dec 5, 2005 at 7:33:36 pm

Well, that works PERFECTLY!!!! Thanks Sher, I NEVER would have come up with that on my own. let me just see if I understand this correctly. If I dynamically load a movie clip onto into the application, the functions for any buttons within that movie clip must be inside the function that loads the movie clip?


Return to posts index


Sher Ali
Re: How do I remove an MC loaded with attachMovie!?!?!?!?
on Dec 6, 2005 at 6:17:27 am

Yes, the functions for any button within that movie clip must be inside the function that loads the movie clip. Alternatively, you can attach code to buttons inside the loaded loaded movie, when you are authoring it.


Sher Ali,
Interactive Media Developer


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]