19 Replies Latest reply on May 2, 2008 6:40 AM by kglad

    unloadClip - unload itself?

    jl2000 Level 1
      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?
        • 1. Re: unloadClip - unload itself?
          kglad Adobe Community Professional & MVP
          either "this" or "this._parent" depending on where you code is located and whether your button is a simple button or a movieclip button.
          • 2. Re: unloadClip - unload itself?
            jl2000 Level 1
            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

            • 3. Re: unloadClip - unload itself?
              kglad Adobe Community Professional & MVP
              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.
              • 4. Re: unloadClip - unload itself?
                jl2000 Level 1
                C1: _level2
                button: _level2.btn_SkipInstructions
                • 5. Re: unloadClip - unload itself?
                  kglad Adobe Community Professional & MVP
                  if you want to unload _level2 and you're using unloadClip, use the number 2 as the target.
                  • 6. Re: unloadClip - unload itself?
                    jl2000 Level 1
                    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


                    • 7. Re: unloadClip - unload itself?
                      kglad Adobe Community Professional & MVP
                      try:

                      mclLoader.unloadClip(_level0.mcHolder);
                      • 8. Re: unloadClip - unload itself?
                        jl2000 Level 1
                        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
                        • 9. Re: unloadClip - unload itself?
                          kglad Adobe Community Professional & MVP
                          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.
                          • 10. unloadClip - unload itself?
                            jl2000 Level 1
                            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
                            • 11. Re: unloadClip - unload itself?
                              kglad Adobe Community Professional & MVP
                              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.
                              • 12. Re: unloadClip - unload itself?
                                jl2000 Level 1
                                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?
                                • 13. Re: unloadClip - unload itself?
                                  kglad Adobe Community Professional & MVP
                                  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);
                                  • 14. Re: unloadClip - unload itself?
                                    jl2000 Level 1
                                    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

                                    • 15. Re: unloadClip - unload itself?
                                      kglad Adobe Community Professional & MVP
                                      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?
                                      • 16. Re: unloadClip - unload itself?
                                        jl2000 Level 1
                                        Sorry - I thought I included that information in my post.
                                        _level0.mcHolder
                                        _level0 [object Object]
                                        • 17. Re: unloadClip - unload itself?
                                          kglad Adobe Community Professional & MVP
                                          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);
                                          • 18. Re: unloadClip - unload itself?
                                            jl2000 Level 1
                                            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

                                            • 19. Re: unloadClip - unload itself?
                                              kglad Adobe Community Professional & MVP
                                              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);