Skip to main content
Known Participant
April 23, 2008
Answered

unloadClip - unload itself?

  • April 23, 2008
  • 10 replies
  • 1219 views
Hi -
I'm using MCL to load full screen swfs onto a "Stage" swf.
On this new child (C1) swf there is a buttn which is supposed to load another clip (C2) and get rid of itself (C1).
I know about unloadClip but how do address C1 from a btn ON C1?
This topic has been closed for replies.
Correct answer kglad
many flash objects when traced do not reveal their instance name. they just reveal that they extend the object class. in your situation you're seeing the results of tracing the moviecliploader instance.

what's important, in your situation, is your finding your moviecliploader is defined or else you'd see undefined traced.

so, back to your original problem, the following should always work when executed after you use your moviecliploader to load something in mcHolder:

_level0.mclLoader.unloadClip(_level0.mcHolder);

10 replies

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 2, 2008
many flash objects when traced do not reveal their instance name. they just reveal that they extend the object class. in your situation you're seeing the results of tracing the moviecliploader instance.

what's important, in your situation, is your finding your moviecliploader is defined or else you'd see undefined traced.

so, back to your original problem, the following should always work when executed after you use your moviecliploader to load something in mcHolder:

_level0.mclLoader.unloadClip(_level0.mcHolder);
kglad
Community Expert
Community Expert
May 1, 2008
then, if you only use loadClip to load into mcHolder, the following will always unload what's been loaded:

_level0.mclLoader.unloadClip(_level0.mcHolder);

and you should NOT see undefined whereever you use that code along with

trace(_level0.mclLoader+" "+_level0.mcHolder);
JLUCCAuthor
Known Participant
May 2, 2008
kglad -
Thanks for the follow thru on this. What term can I look under in the reference docs to learn more about this aspect of AS? I run into this issue often.
What does the response "_level0 [object Object]" mean?
jl

kglad
Community Expert
Community Expert
April 30, 2008
for a variable that contains an absolute path, like (_level0.mcHolder) to return undefined, your trace() function must be executing when _level.mcHolder does not exist.

for a variable without a path (like mclLoader) to return undefined, it either doesn't exist, at all, or it exists but not within the scope of the trace() function.

so, just below the code where mcHolder is created, use:

trace(mcHolder);

and just below the code where mclLoader is created use:

trace(this+" "+mclLoader);
JLUCCAuthor
Known Participant
May 1, 2008
Neither of these traces came back until I clicked on a text link in the menu to bring in a video. So the mc with the code below is in START, Splash had loaded and from there opened Span_GUI - where the menu in question lives.
What have I learned here? I appreciate your input but I dont know the significance of what I'm looking at. Clarification?

JL

kglad
Community Expert
Community Expert
May 1, 2008
to use the trace() function, it doesn't matter what you have to do to get it to execute. but it does matter what the output is. what is the output of those two trace() statements?
kglad
Community Expert
Community Expert
April 29, 2008
that looks like 3 different trace statements, i assume, from 3 different locations. it doesn't appear any of them are within scope of mclLoader or they are executed before mclLoader is defined.

the first two must be executed before mcHolder is created, if you used _level0.mcHolder in your trace statement.
JLUCCAuthor
Known Participant
April 30, 2008
I did use 3 differnt trace statements but added a text string so I could tell which location was sending the trace. I hope this didn't void whatever was returned.
I re-did the same test and the results are below.

What does in mean that mclLoader and mcHolder are undefined in places where I can SEE them in the code?
kglad
Community Expert
Community Expert
April 29, 2008
if _level0.mcHolder is at a non-removable depth then yes, that would prevent you from removing it (with removeMovieClip) from your stage. but it wouldn't prevent you from unloading its contents.

use trace(mclLoader+" "+_level0.mcHolder) to make sure both objects exist.

if they do exist and mclLoader.unloadClip(_level0.mcHolder) does not appear to be unloading whatever was loaded into mcHolder, you should check if you're being fooled: the contents are unloading but you're seeing something that makes you think it's not unloading.
JLUCCAuthor
Known Participant
April 29, 2008
kglad -

GOT IT!
_parent.mcHolder.unloadMovie();

However - Now I'm very, very confused.
I put a trace you suggested right above the code where mcHolder is written. See the result below

As far as being fooled, the swf in mcHolder plays an FLV. When I click the Home btn I can see and hear the audio and video is still playing.

jl
kglad
Community Expert
Community Expert
April 29, 2008
try:

mclLoader.unloadClip(_level0.mcHolder);
JLUCCAuthor
Known Participant
April 29, 2008
kglad - the same result. Is "getNextHighestDepth" messing me up? Since I'm always changing the depth of the things loaded into mcHolder, would that matter?
What if I put everything on a specific level in the whole project? Would that help?
Puzzle.
Thanks
JL
kglad
Community Expert
Community Expert
April 27, 2008
if you want to unload _level2 and you're using unloadClip, use the number 2 as the target.
JLUCCAuthor
Known Participant
April 28, 2008
kglad -
I'm sorry but I have to step back. There are so many things not happening the way I want using the code I provided earlier that I had to strip it down and start over. ( No more preloader, no more shared library.) Then, following your technique I found what I needed to use loadClip to get a new swf into level0.container which would replace whatever was there. Thus I never needed unloadClip at level0.container

Now I the unload issue returns at the "topic" level.

Background: The main GUI, at level0.container, has buttons to go back to the Home screen. It also has menus that bring in topic content on part of the stage. The menus are dynamic text areas in MCs inside an accordion component. In those menus I use the "bringInContent" function below to create "mcHolder" on half the stage and load it with any topic swf. It works perfectly - until the user wants to go back Home. Clicking the Home buttn brings up Home "behind" mcHolder and they both play at once.

The topic swf is inside mcHolder but the GUI with the menu and the Home btn is in _level0.container.

When I tried - trace("C1: "+this) on the timeline with the GUI; - I got - _level0.container
When I tried - trace("button: "+this); on the Home button, I got - _level0.container.btn_Home.
When I added these to the bringInContent function, I got - _level0.mcHolder
Makes perfect sense but I couldn't figure out how to use this information to unload mcHolder AND switch out swfs in container to load Home.

You can see some of the variations I tried below.

Please help. I can get Home onto the stage but how do I get mcHolder off.
JL


JLUCCAuthor
Known Participant
April 26, 2008
C1: _level2
button: _level2.btn_SkipInstructions
kglad
Community Expert
Community Expert
April 26, 2008
on C1's timeline place:

trace("C1: "+this);

and attached to your button press handler place:

trace("button: "+this);

test your movie and press that button. paste the output panel results here.
kglad
Community Expert
Community Expert
April 23, 2008
either "this" or "this._parent" depending on where you code is located and whether your button is a simple button or a movieclip button.
JLUCCAuthor
Known Participant
April 24, 2008
kglad - thanks for the reply.
It's a simple button. With your two suggestions I either got a blank screen or the two swfs overlapping. The button in question is on Splash. Here's the hierarchy of the site (took a level out since yesterday):

START (graphic background) - - - level0 (?)
...Splash
...Eng-FAQ
...Eng
......topic_e1
.........fopic_e1.flv
......topic_e2
.........fopic_e2.flv
...Span-FAQ
...Span
......topic_s1
.........fopic_s1.flv
......topic_s2
.........fopic_s2.flv

Just to be sure I need to ask this...If START is level0 then; Splash, Eng-FAQ, Eng, Span-FAQ and Span are all level1?? And then topic_e1,e2,s1 & s2 are level2 ?? Is that so?
Is this level numbering changed if I put "this._lockroot = true;" on all the swfs except START?

TIA your coaching.
JL