8 Replies Latest reply on Mar 9, 2007 8:52 AM by Newsgroup_User

    Action at end of FLV playback?

    shueardm Level 1
      Would like to put an action at the end of a FLV playback which goes for 3 minutes. Instead of creating 3000 frams and putting an end action there, can I put an action in the FLV file to close the movie and open another?
      Thanks
        • 1. Re: Action at end of FLV playback?
          Level 7
          shueardm,

          > Would like to put an action at the end of a FLV playback
          > which goes for 3 minutes. Instead of creating 3000 frams
          > and putting an end action there

          Wow, yes! Yes, much better way to go. :)

          > can I put an action in the FLV file to close the movie and
          > open another?

          It's a little more complicated than that -- but not much. I find it
          helps in a BIG WAY to understand a few basic concepts about how objects are
          put together in ActionScript.

          a) objects are defined by classes
          b) classes determine an objects:
          1) properties (characteristics)
          2) methods (things it can do)
          3) events (things it can react to)

          So in this case, you want to react to the end of a video. That's an
          event.

          Normally, I would send you to the ActionScript 2.0 Language Reference
          and encourage you to look up the "FLVPlayback class" entry there. In the
          ASLR, properties, methods, and events tend to be listed all on the same page
          for each object -- makes it very convenient. For better or worse, the
          Components Language Reference (which contains the FLVPlayback class entry)
          isn't arranged in quite the same way. You have to do a bit more digging,
          and in the case of FLVPlayback, the issue is further complicated by the fact
          the this class extends another one -- the reference says it "wraps the
          VideoPlayer class" -- so in this case, the asnwer lies int he VideoPlayer
          class. Particularly, the VideoPlayer.complete event.

          But thanks to inheritance, this event applies to FLVPlayback itself. So
          ....

          Put a stop(); action right in the frame that your FLVPlayback Component
          first appears. The timeline playhead will stop, but the *video* playhead
          will keep playing until it hits the end of its own special video timeline.
          At that point, the VideoPlayer.complete event will be dispatched under the
          auspices of the FLVPlayer class.

          Beneath your stop() action, then, put this:

          var listener:Object = new Object();
          listener.complete = function():Void {
          // whatever you want to happen
          }
          videoPlayer.addEventListener("complete", listener);

          Important: without an instance name, the above won't work. You must
          put an instance name on your FLVPlayback instance. In my suggested code,
          the instance name is videoPlayer -- but it's up to you.


          • 2. Re: Action at end of FLV playback?
            Level 7
            > Important: without an instance name, the above won't
            > work. You must put an instance name on your
            > FLVPlayback instance. In my suggested code, the
            > instance name is videoPlayer -- but it's up to you.

            Can't stress that point enough. ;)


            David Stiller
            Adobe Community Expert
            Dev blog, http://www.quip.net/blog/
            "Luck is the residue of good design."


            • 3. Re: Action at end of FLV playback?
              shueardm Level 1
              David,

              I thank you very much for the detailed description. That method works perfectly.

              Cheers
              • 4. Re: Action at end of FLV playback?
                kwlowe
                This is by far the easiest to follow instruction I've seen so far. Pretty sad that I still can't make it work. My situation is thus:

                I have a single scene timeline with multiple layers to contain various graphics and buttons, but only three frames. In frame one, I have a masked graphic with an invisible button over it that when clicked goes to frame 2. It is at this point that my flv starts playing. I want it to, when the video is finished, go to frame 3. I've tried placing the code below in the exact frame my FLV player component is in (created FLV w/sorenson spark using import video) I'm a total novice with scripting of any kind, but desperate to get this to work:

                stop();

                var listener:Object = new Object();
                listener.complete = function():Void {
                gotoAndPlay(3);
                };
                murphy_flv.addEventListener("complete",listener);


                (murphy_flv is the instance name of my player component.)

                Any ideas? Been at this for four days and nothing seems to work.

                Thanks in advance,

                Kevin
                • 5. Re: Action at end of FLV playback?
                  Level 7
                  Kevin,

                  > I've tried placing the code below in the exact frame my FLV player
                  > component is in (created FLV w/sorenson spark using import video)
                  > I'm a total novice with scripting of any kind, but desperate to get this
                  > to work:

                  Sounds like it's time for some troubleshooting! :)

                  > var listener:Object = new Object();
                  > listener.complete = function():Void {
                  > gotoAndPlay(3);
                  > };
                  > murphy_flv.addEventListener("complete",listener);

                  First thing I would do, Kevin, is put a trace() statement in front of
                  that gotoAndPlay() function call to see if the complete even is firing at
                  all.

                  var listener:Object = new Object();
                  listener.complete = function():Void {
                  trace("complete event was fired");
                  gotoAndPlay(3);
                  };
                  murphy_flv.addEventListener("complete", listener);

                  This code uses post colon suffices (the :Object and :Void), so it needs
                  to be published as ActionScript 2.0. Check your publish settings, and let
                  me know if you see the "complete event was fired" message in your Output
                  panel.


                  David Stiller
                  Adobe Community Expert
                  Dev blog, http://www.quip.net/blog/
                  "Luck is the residue of good design."


                  • 6. Action at end of FLV playback?
                    kwlowe Level 1
                    Wow you're fast!

                    The trace didn't popup in my output box, so I'm guessing that failed. Checked publish settings - targeting flash 8, AS 2.0. The FLV and the SWF are in the same folder.

                    Current code:

                    stop();

                    var listener:Object = new Object();
                    listener.complete = function():Void {
                    trace("complete event was fired");
                    _root.gotoAndPlay(3);
                    };
                    murphy_flv.addEventListener("complete",listener);

                    Other things of note: Parameters on the FLV component:
                    autoPlay = true
                    autoRewind = true
                    no cuepoints
                    isLive - false
                    totalTime - 0

                    REALLY appreciate you for taking the time to help!

                    Kev.
                    • 7. Re: Action at end of FLV playback?
                      kwlowe Level 1
                      Figured this one out. Key point here is that you cannot utilize cue points at or very near the end of the FLV. It won't recognize them. When I moved the cue point back in time about a half second, it worked perfectly using this code:

                      stop();
                      var listenerObject:Object = new Object();
                      listenerObject.cuePoint = function(eventObject:Object):Void {
                      gotoAndPlay(3)
                      }
                      player.addEventListener("cuePoint", listenerObject);

                      This code assumes your FLVPlayer component has an instance name of "player", and used an Action Script cuepoint placed near but not at the end of the FLV. Flash is Version 8, AS 2.0.

                      What a long night!

                      Thanks for the direction,

                      Kev.
                      • 8. Re: Action at end of FLV playback?
                        Level 7
                        Kevin,

                        > Figured this one out. Key point here is that you cannot
                        > utilize cue points at or very near the end of the FLV.

                        Hey, good sleuthing! I'm surprised by your findings, but hey, as long
                        as you were able to fix your issue ... that's what counts.


                        David Stiller
                        Adobe Community Expert
                        Dev blog, http://www.quip.net/blog/
                        "Luck is the residue of good design."