3 Replies Latest reply on Apr 21, 2009 4:31 AM by Javier P.

    Pausing a linked .flv with actionscript

    Geisen
      Hi all.

      Let me preface by saying that I'm fist-and-foremost a designer... and an actionscript novice.

      I have an external .flv and I simply need to be able to pause it with a frame action and start it back up with another frame action.

      I found some references to "flvStream.play" through google but I haven't been able to properly implement it.

      Any help would be greatly appreciated. Thanks in advance.
        • 1. Re: Pausing a linked .flv with actionscript
          Level 7
          Geisen,

          > I have an external .flv and I simply need to be able to
          > pause it with a frame action and start it back up with
          > another frame action.

          The most important tip I can share with you is this: think in terms of
          objects. An FLV video, external or not, is a file format that needs a bit
          of help getting displayed. A very popular approach is to use the
          FLVPlayback Component (see the Components panel), which includes a number of
          configurable (and optional) "skins" that allow for pausing, playing, volume
          control, etc. The FLVPlayback Component, in that scenario, is your object.
          Many people use a Video asset from the Library in cahoots with something
          called NetConnection and NetStream, in which case you're dealing with three
          objects (Video, NetConnection, and NetStream) that collaborate. Going back
          further, there are Media Components that provide much of the functionality
          of FLVPlayback, in which case the focus of your object(s) changes again.

          In all cases, objects are defined by something called classes. Movie
          clips are defined by the MovieClip class, text fields by the TextField
          class, FLVPlayback by the FLVPlayback class, and so on. Classes define
          objects in the way a recipe defines a certain kind of cake or a blueprint
          defines a certain kind of structure. In the ActionScript 2.0 Language
          Reference, you'll find that most classes list one or more of the following
          three headings: properties (characteristics of the object), methods (things
          the object can do), and events (things the object can react to). In the
          ActionScript 3.0 Langauge Reference (if you have Flash CS3), you'll find the
          same format, with the occasional additional heading. From a bird's eye
          view, however, the layout is the same: objects have certain properties, and
          can do certain things and react in certain ways (to button clicks, internal
          timers, etc.) -- and it's the combination of these qualities that makes a
          given object the type it is (e.g., text fields don't have timelines, so the
          TextField class doesn't mention anything about a text field's current frame,
          yet text fields and movie clips both have width and height, and both their
          classes mention as much).

          So ... the way you're going to pause your FLV video depends on entirely
          on the object(s) being used to display that video. If you're using
          FLVPlayback, you'll have to give that Component on the Stage an instance
          name (see the Property inspector while the Component is selected). Instance
          names allow ActionScript to speak directly to individual instances of an
          object -- this particular FLVPlayback in the lower left, for example, rather
          than the other one in the upper right.

          Once it has an instance name, you can reference that name and invoke
          FLVPlayback class members on that instance. If you've given it the instance
          name myPlayer, you would invoke FLVPlayback.pause() (the pause method) as
          follows:

          // In a keyframe of your scripts layer ...
          myPlayer.pause();

          And to start it up again, you would invoke FLVPlayback.play() (the play
          method) at a later keyframe like this:

          myPlayer.play();

          If you're using a combination of a Video element from the Library and
          the NetConnection and NetStream classes, you'll reference your NetStream
          object by its instance name (this will be the variable you use to
          instantiate the object) and invoke NetStream.pause(), and so on.

          Here are a few articles in ActionScript 2.0 on the topic:

          http://www.quip.net/blog/2006/flash/how-to-load-external-video
          http://www.quip.net/blog/2006/flash/how-to-control-flv-without-component
          http://www.quip.net/blog/2007/flash/actionscript-20/how-to-determine-completion-of-flv/

          Those should at least get you a bit more comfortable with the idea of
          classes, objects, and their members (properties, methods, and events). If
          you're building a movie in ActionScript 3.0, the syntax may change ... not
          so much for quick method calls, but certainly for event handling. For what
          you're described, even these AS2 examples should be helpful.


          David Stiller
          Co-author, Foundation Flash CS3 for Designers
          http://tinyurl.com/2k29mj
          "Luck is the residue of good design."


          • 2. Re: Pausing a linked .flv with actionscript
            Geisen Level 1
            Wow. Thanks David.

            That was incredibly simple. Worked like a charm.

            I'm in your debt.

            • 3. Re: Pausing a linked .flv with actionscript

              Hi.

               

              I'm a newbe in Flash, and I have the same question. I need to put some lines of code in AS3 to pause and to release a video with the

              FLVPlayback control. I follow the steps in the answer of David, but does not work in my case (probably because I have done something wrong).

               

              I would appreciate very much, a small sample about that (if possible)

               

                          Thanks. Javier.