13 Replies Latest reply on Aug 23, 2007 7:31 AM by edmundep2

    loadMovie/unloadMovie question

    xenoyoke Level 1


      I am loading two different media types on relase of two different buttons into same flv_player. Loading the image I use loadMovie, and for loading the .flv I am using a different method. Having unloadMovie in the button that is loading the flv movie prevents that instance from loading at all! Yet in the other instance it works.... This is best demonstrated if I show you the code:

      For loading the image via button 1:
      on (release) {
      flv_play.unloadMovie();
      flv_play.loadMovie("weddings/wedding1/photos/large/1-wedding-064.jpg");
      }

      For loading the video via button 2:

      on (release) {
      /**
      Requires:
      - FLVPlayback component on the Stage with an instance name of flv_play
      */

      flv_play.unloadMovie();
      import mx.video.*;
      flv_play.contentPath = "weddings/wedding1/videos/large/vid1.flv";
      var listenerObject:Object = new Object();
      listenerObject.metadataReceived = function(eventObject:Object):Void {
      flv_play.setSize(flv_play.preferredWidth, flv_play.preferredHeight);
      }

      flv_play.addEventListener("metadataReceived", listenerObject);

      }


      Any crumb of input would be so appreciated I have spent hours trying soooo many different ways to be able to load video, then load the picture (which always works) but then when I go back to load the video again, it won't load anything. Please please help me.

        • 1. Re: loadMovie/unloadMovie question
          edmundep2 Level 1
          not sure why but i have found that using unloadMovie actually gets rid of the reference to that clip..
          try adding trace(flv_play) and see what you get back after calling unloadMovie
          • 2. Re: loadMovie/unloadMovie question
            xenoyoke Level 1
            Okay, I tried that and I'm not sure how to make use of the output.

            Also, I'm having this same problem in a new way now - I'm making a nav bar that loads an external flv on rollover, and on rollout I wish to unload the movie - this works, except that when I rollover again the movie doesn't load again.

            This is similar behavior as I saw in my hours of troubleshooting the problem mentioned above...

            It's as if once I unload the instance into which I'm 'loading' my flv (which I'm not doing via loadmovie I'm setting the contentpath and all that)... once I unload the instance I'm unable to load it again but ONLY when dealing with the flv's.

            Here's a simpler example of the code (kind of) and the trace output will follow:
            on (rollOver) {

            import mx.video.*;
            nav1.contentPath = "nav/nav2.flv";
            var listenerObject:Object = new Object();
            listenerObject.metadataReceived = function(eventObject:Object):Void {
            nav1.setSize(nav1.preferredWidth, nav1.preferredHeight);
            }
            nav1.addEventListener("metadataReceived", listenerObject);

            }

            on (rollOut) {

            unloadMovie ("nav1");
            trace(nav1);

            }

            and on rollout I'm returned:
            _level0.instance2.nav1

            I am so happy you replied you have no idea. I'm about to cry over this I need this whole site done by Friday and this weird problem has been halting development for days now! I have read so many google results with no luck please help if you can give any hint no matter how small. !! : )
            • 3. Re: loadMovie/unloadMovie question
              xenoyoke Level 1
              "unloadMovie actually gets rid of the reference to that clip.."

              is it possible that re-invoking the reference using this code just isn't possible?

              import mx.video.*;
              nav1.contentPath = "nav/nav2.flv";
              var listenerObject:Object = new Object();
              listenerObject.metadataReceived = function(eventObject:Object):Void {
              nav1.setSize(nav1.preferredWidth, nav1.preferredHeight);
              }
              nav1.addEventListener("metadataReceived", listenerObject);
              • 4. loadMovie/unloadMovie question
                edmundep2 Level 1
                Try this code and see if that fixes your problem.
                The problem i think your having is a problem with the FLVPlayback component.. if you try and set its contentPath over and over again the player never actually calls play or sometimes never loads the video.. but setting the activeVideoPlayerIndex to something different than the default(0) actualy creates a new video Instance inside the component and loads the video onto that.

                and btw never ever have an import inside of a rollover function thats just bad code ;)
                • 5. loadMovie/unloadMovie question
                  xenoyoke Level 1
                  thank you I am trying that now..

                  If the import is not in the button, what other object am I to attach the action to??


                  duh nevermind I see that you placed it above the actual roll actions. on first try this had syntax errors everywhere but going to troubleshoot now. sorry for the immediate duh response.
                  • 6. Re: loadMovie/unloadMovie question
                    edmundep2 Level 1
                    the import is just a one time call that flash uses to get the right resources files to use if you are typing things.. you dont need to attach any action to anything....
                    not sure i understand what you are asking?
                    • 7. Re: loadMovie/unloadMovie question
                      xenoyoke Level 1
                      The compiler is throwing errors on everything that is outside of an 'on' handler...
                      specifically lines 1,2,3,4,6.

                      Tried a shot in the dark putting those lines in an on load handler and that threw even more errors that I haven't looked at yet.

                      Again, please excuse my initial response...
                      • 8. Re: loadMovie/unloadMovie question
                        edmundep2 Level 1
                        where is this code sitting??....
                        if its on a button remove it and put it on the timeLine..
                        then change your on(rollOver) calls to

                        var _this = this;
                        buttonsInstanceName.onRollOver = function(){
                        _this.loadMyMovie();
                        }

                        function LoadMyMove(){
                        /// put the onRollOver old code in here ex: nav1.contentPath etc...
                        }

                        do the same for the on rollOut

                        putting everything on a button you can easily lose scope of your instances on the stage..
                        • 9. Re: loadMovie/unloadMovie question
                          xenoyoke Level 1
                          Okay... I put it all on the timeline. Here is the code... when I rollover, nothing happens. Using trace(nav2)(I changed it to nav2) I'm not getting anything useful back...

                          import mx.video.*;
                          var listenerObject:Object = new Object();
                          nav2.addEventListener("metadataReceived", listenerObject);
                          var index = 0;

                          listenerObject.metadataReceived = function(eventObject:Object):Void {
                          nav2.setSize(nav2.preferredWidth, nav2.preferredHeight);
                          }

                          var _this = this;
                          buttonsInstanceName.onRollOver = function(){
                          _this.loadMyMovie();
                          }

                          function loadMyMovie(){
                          /// put the onRollOver old code in here ex: nav2.contentPath etc...

                          index++;
                          nav2.activeVideoPlayerIndex = index;
                          nav2.contentPath = "nav/nav2.flv";
                          }


                          var _this = this;
                          nav_play.onRollOut = function(){
                          _this.unloadMyMovie();
                          }

                          function unloadMyMovie(){
                          unloadMovie(nav2);
                          }

                          Is this right?
                          • 10. Re: loadMovie/unloadMovie question
                            xenoyoke Level 1
                            LoadMyMove vs. loadMyMovie is the casing difference on purpose? I don't believe it worked before I made the casing consistent but I'm going back to try that again...

                            also... does _this need to change for rollout code? I think I'm going to just try to get the onRollOver to work first now in any case.

                            Your help is so appreciated you have no idea. I have spent every working hour outside of 'real' work googling and troubleshooting this for a week.
                            • 11. Re: loadMovie/unloadMovie question
                              xenoyoke Level 1
                              this doesn't work either. I'm still trying to figure this out..

                              import mx.video.*;
                              var listenerObject:Object = new Object();
                              nav2.addEventListener("metadataReceived", listenerObject);
                              var index = 0;

                              listenerObject.metadataReceived = function(eventObject:Object):Void {
                              nav2.setSize(nav2.preferredWidth, nav2.preferredHeight);
                              }

                              var _this = this;
                              nav_play.onRollOver = function(){
                              _this.loadMyMovie();
                              }

                              function LoadMyMove(){
                              /// put the onRollOver old code in here ex: nav2.contentPath etc...
                              index++;
                              nav2.activeVideoPlayerIndex = index;
                              nav2.contentPath = "nav/nav2.flv";
                              }

                              • 12. Re: loadMovie/unloadMovie question
                                xenoyoke Level 1
                                Okay, this code works to load and unload the movie on roll on/out... but still having that same issue as before that the movie won't RE-load when I re-enter mouse area.... Why is unloading the movie seeming to permanently unload it?

                                import mx.video.*;
                                var listenerObject:Object = new Object();
                                nav2.addEventListener("metadataReceived", listenerObject);
                                var index = 0;

                                listenerObject.metadataReceived = function(eventObject:Object):Void {
                                nav2.setSize(nav2.preferredWidth, nav2.preferredHeight);
                                }

                                var _this = this;
                                nav_play.onRollOver = function(){
                                _this.loadMyMovie();
                                }

                                function loadMyMovie(){
                                nav2.activeVideoPlayerIndex = index;
                                nav2.contentPath = "nav/nav2.flv";
                                }

                                nav_play.onRollOut = function(){
                                _this.unloadMyMovie();
                                }

                                function unloadMyMovie(){
                                unloadMovie(nav2);
                                }

                                • 13. Re: loadMovie/unloadMovie question
                                  edmundep2 Level 1
                                  change your content path to null instead of unloading the movie on rollOut