5 Replies Latest reply on Nov 13, 2007 6:05 PM by Newsgroup_User

    Stop 1 movie when playing another

    eddiwill9
      I have a project with 5 flv files in it. I have buttons to take the user to whichever clip they would like to hear (they are audio only, with controllers).

      The problem is, once you have started any of the clips playing, if you click to go to another one, the first one continues to play at the same time. Is there a simple script to tell whatever may already be playing to stop before the other one begins?

      This is my first Flash project,btw-- I don't know anything! :)
        • 1. Re: Stop 1 movie when playing another
          Level 7
          eddiwill9,

          > The problem is, once you have started any of the clips playing,
          > if you click to go to another one, the first one continues to play
          > at the same time.

          Tat would make sense, actually, because those FLVs each have their own,
          independent timelines as well.

          > Is there a simple script to tell whatever may already be playing
          > to stop before the other one begins?

          It all depends on what you're using to play those FLVs. Are you using,
          say, the FLVPlayback Component? If so, then it's as simple as looking up
          the FLVPlayback class in the pertinent ActionScript Language Reference to
          see what properties, methods, and events are available for that object.

          See, classes define objects -- they're like recipes, or blue prints --
          so they give you everything you need in order to use the objects they
          define. If you're working with a movie clip, look up the MovieClip class.
          If you're working with a button symbol, look up the Button class (AS2) or
          the SimpleButton class (AS3). If you're working with a text field, look up
          the TextField class, and so on. Properties are the characteristics of that
          object, methods are things it can do, and events are things it can react to.

          By the sound of it, you're sending the user to a new frame in the main
          timeline, meanwhile, you haven't instructed your FLVPlayback instance (I'm
          assuming) to stop playing. In order to be able to speak to that object,
          you'll have to give it an intance name. Symbols and components can be given
          instance names by way of the Propery inspector. Click the object to select
          it, then look at the upper left of the Property inspector and you'll see it.

          Whatever instance name you give it, that's your "handle" to that object.
          If the object is a movie clip, you can invoke movie clip methods on it, such
          as MovieClip.play() or MovieClip.stop(). If the instance name was, for
          example, froggy, you would invoke MovieClip.stop() like this:
          froggy.stop().

          See if this gets you started, and don't hestitate to write back if you
          need to. Make sure to specify which version of ActionScript your using. :)


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


          • 2. Re: Stop 1 movie when playing another
            eddiwill9 Level 1
            Yes, I am using the FLV component-- it seemed the simplest way.

            quote:

            By the sound of it, you're sending the user to a new frame in the main timeline


            Yes; that's exactly how I am doing it.

            quote:

            If the instance name was, for example, froggy, you would invoke MovieClip.stop() like this:
            froggy.stop().


            I "almost" understand you here. But it looks like (and I may be wrong) that this stops only a specific clip. What if you were on "kitty" rather than "froggy". It would seem like some sort of more global stop would be called for since you don't know which clip you are going to be coming from. Does that make sense?
            • 3. Re: Stop 1 movie when playing another
              Level 7
              eddiwill9,

              >> If the instance name was, for example, froggy, you would
              >> invoke MovieClip.stop() like this: froggy.stop().

              > I "almost" understand you here. But it looks like (and I may be wrong)
              > that this stops only a specific clip.

              That's exactly right! You and I, we're both instances of the Human
              class. Each of us shares properties, methods, and events shared by all
              humans. If someone (or something) shouted, "Whoa, duck!" it would be awful
              if every human being ducked. That's why the communication goes one-on-one.

              > What if you were on "kitty" rather than "froggy". It would seem like some
              > sort of more global stop would be called for since you don't know which
              > clip you are going to be coming from. Does that make sense?

              I'm proposing that you drag only a single FLVPlayback instance to your
              Stage. Give it an instance name -- let's say videoPlayer (which is a little
              more helpfully descriptive than kitty or froggy -- but same concept). Now
              that this one instance has an instance name, you can invoke FLVPlayback
              class members on it.

              In frame 1, for example, you could set its contentPath property to a
              video about frogs.

              videoPlayer.contentPath = "frogs.flv";

              In frame 2, you could set its contentPath property to a video about
              kittens. There's really no need for more than on instance of FLVPlayback on
              the Stage (though there isn't anything illegal about it, either). I know
              you can set properties on FLVPlayback components (and any component) in the
              Parameters tab, but those parameters are nothing more than properties. The
              available properties depend on what class you're dealing with.

              If you really wanted to use more than one FLVPlayback instance, you
              would give each one its own instance name and use the relevant instance name
              as your object reference prefix. Either which way, you'll find methods like
              pause(), play(), stop(), and others that would make sense for an object like
              this one.

              For FLVPlayback, you'll actually have to look in the Components Language
              Reference for ActionScript 2.0. If you're using Flash CS3 and have access
              to Actionscript 3.0, you'll find that even the components are listed in the
              ActionScript Language Reference, which is really helpful.


              David Stiller
              Contributor, How to Cheat in Flash CS3
              http://tinyurl.com/2cp6na
              "Luck is the residue of good design."


              • 4. Re: Stop 1 movie when playing another
                EddieWilliams
                I'm going to try using only 1 FLVPlayback instance and just calling each FLV into a particular keyframe that the corresponding button will point to.

                Will that automatically stop one from playing when moving to the other-- since it's using the one and only FLVPlayback instance?
                • 5. Re: Stop 1 movie when playing another
                  Level 7
                  EddieWilliams,

                  > I'm going to try using only 1 FLVPlayback instance and
                  > just calling each FLV into a particular keyframe that the
                  > corresponding button will point to.

                  Make sure to omit keyframes, other than the first one, for this
                  instance.

                  > Will that automatically stop one from playing when moving
                  > to the other-- since it's using the one and only FLVPlayback
                  > instance?

                  That, in addition to the fact that new FLVs will be loaded as a result
                  of a change to the component's contentPath (AS2) / source (AS3) property,
                  should do it. Come back, though, if you get lost.


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