12 Replies Latest reply on Aug 24, 2007 5:36 PM by J.Rocker

    Why doesnt this work?

    J.Rocker Level 1

      This is a pretty complex code, but i could really use some help.
        • 1. Re: Why doesnt this work?
          kglad Adobe Community Professional & MVP
          externalMovie is local to finished_loading. remove the var prefix.
          • 2. Re: Why doesnt this work?
            J.Rocker Level 1
            but since everything that references externalmovie is inside the function isnt it alright? taking off the prefix and moving it outside the function both cause errors.

            my problem is the unloading of the movies, i get this error when i try and remove them.
            "ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
            at flash.display::DisplayObjectContainer/removeChild()
            at MethodInfo-603()
            "

            Thank you kglad
            • 3. Re: Why doesnt this work?
              kglad Adobe Community Professional & MVP
              try:

              • 4. Re: Why doesnt this work?
                J.Rocker Level 1
                Thanks kglad, that worked!
                but, i'm still having trouble with my portfolio.

                for whatever reason, when first change the movie, it works and what i want to display works. But if i exit out (which isnt effectivly changing it back to the default SWF, yet it changes back anyway (possibly because the first swf wasnt completely removed from my viewport, and some confused variables are referencing it and that brings it back). after i exit back and it changes back to the first movie clip, though, when i cick on a different button (which should bring a different (than any so far)) swf, it changes to the swf that came up with the origonal button.

                This is all caused by ineffective removeChild commands or variables that are magically bringing back old movie clips.

                >:0(

                I want out.

                Help please?
                • 5. Re: Why doesnt this work?
                  kglad Adobe Community Professional & MVP
                  is anything in your last message related to the code you posted? if so, please explain.
                  • 6. Why doesnt this work?
                    J.Rocker Level 1
                    Yeah, this is all part of a code on a frame that's 2800 lines long.

                    i changed it a few times to try and get everything to work right, but so far no success.

                    I'll try and give a better look at it.
                    • 7. Why doesnt this work?
                      J.Rocker Level 1
                      should i possibly use
                      loader.unload();?

                      // Make request and loader
                      var request:URLRequest = new URLRequest(" http://www.[yourdomain
                      var loader:Loader = new Loader();

                      // This is done after the swf is loaded.
                      function finished_loading (e:Event) {
                      var externalMovie = MovieClip(loader.content); // cast 'DisplayObject' to 'MovieClip'
                      stage.addChild(externalMovie); // add your swf directly to the stage
                      externalMovie.gotoAndPlay("start"); // Now you can use all MovieClip methods!
                      }

                      // Tell the loader to call 'finished_loading' after the swf is loaded.
                      import flash.events.Event;
                      loader.contentLoaderInfo.addEventListener(flash.events.Event.COMPLETE, finished_loading);

                      // Start loading.
                      loader.load(request);
                      • 8. Re: Why doesnt this work?
                        kglad Adobe Community Professional & MVP
                        you should be adding your loader to the display list. then you can remove it later when you want.
                        • 9. Why doesnt this work?
                          J.Rocker Level 1
                          Ok, i added the loader to the display list as a child of view14.

                          now by using
                          view14.removeChild(loader) it does unload,
                          im still testing to see if it's a success, and i hope it is.

                          [EDIT]
                          i got "parameter child must be non-null" which makes me wonder when i'm supposed to remove it.
                          • 10. Re: Why doesnt this work?
                            kglad Adobe Community Professional & MVP
                            loader needs to be in scope. if it's created in a function body don't prefix it with var (which makes it local to that function).
                            • 11. Re: Why doesnt this work?
                              J.Rocker Level 1
                              I did remove the prefixes, i noticed that it didnt show in the code i posted. Thank you very much, by the way.

                              I'm actually getting some success by deconstructing my functions. it seem removeChild is picky about where you place it in a function, but so far it's been working when it's first.

                              Right now its been removed correctly in two cases but i have about 2 more that i need to check out.
                              • 12. Why doesnt this work?
                                J.Rocker Level 1
                                Repeated post