5 Replies Latest reply on Jul 3, 2007 7:24 PM by Newsgroup_User

    Is there any way to use a Marker placed in an FLV to trigger a scripted page turn in a Flashpaper swf?

    mattcurylo
      Is there any way to use a Marker placed in an FLV to trigger a scripted page turn in a Flashpaper swf if both are embedded on the same page?
      Any help you can throw on this will be appreciated.

      Matt Curylo
      mcurylo@slp3d.com
        • 1. Re: Is there any way to use a Marker placed in an FLV to trigger a scripted page turn in a Flashpaper swf?
          Level 7
          Matt,

          > Is there any way to use a Marker placed in an FLV to trigger a
          > scripted page turn in a Flashpaper swf if both are embedded on
          > the same page?

          Yes. In fact, it doesn't matter if the movies are embedded on the same
          page or not. The LocalConnection class allows two SWFs to communicate as
          long as they are running on the same computer, whether both are in the same
          page, in two pages of the same browser, different browsers, or even if one
          or both are in a stand-alone Projector.

          > Any help you can throw on this will be appreciated.

          Sure thing. You've got two goals. First, you'll need to listen for cue
          points in the FLV. Second, you'll need to send a message from one SWF to
          another via an instance of LocalConnection. The receiving SWF will have to
          load your FlashPaper movie and use the FlashPaper API to send the document
          to the desired page.

          Are you using ActionScript 2.0?


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


          • 2. Re: Is there any way to use a Marker placed in an FLV to trigger a scripted page turn in a Flashpaper swf?
            mattcurylo Level 1
            Hi David,
            Thanks for responding so fast.

            We are currently using AS2 for the majority of projects, and now dabbling into AS3 in Flex.

            Thanks again,
            Matt
            • 3. Re: Is there any way to use a Marker placed in an FLV to trigger a scripted page turn in a Flashpaper swf?
              Level 7
              Matt,

              > We are currently using AS2 for the majority of projects, and now
              > dabbling into AS3 in Flex.

              Okay, I'll give you some guidance in the AS2 direction, and you'll be
              able to carry the principle across to AS3 when you take that route.

              First, you've got to embed your cue points. When you import a video
              file (let's say an AVI) into Flash, the Encoding screen (Flash 8) in the
              import wizard gives you an advanced settings button. Click that, and you
              get tabs, which include a Cue Points tab. Drag the preview scrubber to find
              a location in the video. Click the + (plus) button to add a cue point at
              that location. By default, it's named "New Cue Point". The Time column
              shows the time of that location. Leave the Type on "Event." In the
              Parameter section, you can click the + (plus) there and add as many
              parameters as you'd like. Add one called, say, "page" and give it a value
              of 12. (The details are up to you, of course; I'm just illustrating how
              these settings will correspond to what you get back from ActionScript.).
              Finish the process and create your FLV, which now has at least one cue point
              in it.

              Next, you have to handle the FLVPlayback.cuePoint event. (There are
              other ways to play video, but I'll assume you're using the FLVPlayback
              Component.) Give your FLVPlayback Component an instance name on the Stage
              via the Property inspector. Let's say you name it myVideo. In a keyframe,
              type the following:

              var listener:Object = new Object();
              listener.cuePoint = function(evt:Object):Void {
              for (var prop:String in evt.info) {
              trace(prop);
              }
              };
              myVideo.addEventListener("cuePoint", listener);

              There are a number of ways to handle events in AS2, and this is one of
              them -- just happens to be the one that suits FLVPlayback events in AS2. An
              arbitrary variable, listener, is set to an instance of the Object class.
              This generic object will act as the liaison or amabassor for events
              dispatched by the Component. A function is assigned to the cuePoint
              property of this object (it doesn't have such a property, but we're adding
              it, here). This function receives a parameter arbitrarily named evt (for
              "event"). The FLVPlayback.cuePoint event carries with it an object of its
              own, like carry-on luggage. This object (here evt) has an info property,
              and this info property refers to the cue point data you entered in earlier.
              By using a for..in loop, you can see the names of those properties when the
              cue point occurs: parameters, type, time, and name. If they look familiar,
              you're following along just fine. :) The parameters property is going to
              have a page property, because of the earlier work. To nab that, just name
              its path:

              var listener:Object = new Object();
              listener.cuePoint = function(evt:Object):Void {
              trace(evt.info.parameters.page);
              };
              myVideo.addEventListener("cuePoint", listener);

              By changing the ActionScript like that, you'll see the number 12 in the
              Output panel, because that's the value you gave the page property (of the
              parameters propery) earlier.

              So more or less half the goal is complete. We've received valuable
              information from a cue point in an FLV file. Now, to send it off to another
              SWF.

              In the "receiving" FLA, the one that loads the FlashPaper SWF, you'll
              need something like the following.

              var lc:LocalConnection = new LocalConnection();
              lc.updateFP = function(page:Number) {
              container.getIFlashPaper().setCurrentPage(page);
              };
              lc.connect("fpConnection");

              I'm assuming that by the time this code is encountered, your FlashPaper
              SWF has already loaded by this second movie. At this point, then, an
              arbitrary variable, lc, is declared and set to an instance of the
              LocalConnection class. Next, in a process not unlike event handling as seen
              above, a function is assigned to a newly created updateFP property of this
              lc instance. I chose updateFP for "update the Flash Paper," but choose a
              name that makes sense to you. This function receives a parameter,
              arbitrarily named page (it'll be receiving a page number from the other
              movie). The function performs the following: per the FlashPaper API ...

              http://www.adobe.com/support/documentation/en/flashpaper/2/flashpaper_api/flashpaper_api3. html

              ... it references a movie clip named container (this part, I made up -- it's
              just the instance name I would use for a loader movie clip) and invokes on
              that container the getIFlashPaper() method, which returns a reference to the
              loaded FlashPaper SWF. Next, it invokes the setCurrentPage() method on that
              returned reference and tells it to go to the page given by the incoming
              parameter. Finally, the lc instance is associated with a particular
              connection. The name is arbitrary, but since we're dealing with FlashPaper,
              I called it fpConnection.

              Now, back to the other movie. We need to create a LocalConnection
              instance in that movie, too, and actually *send* a message across the same
              "fpConnection" connection. Change the cuePoint event handler to look like
              this:

              var lc:LocalConnection = new LocalConnection();

              var listener:Object = new Object();
              listener.cuePoint = function(evt:Object):Void {
              lc.send("fpConnection", "updateFP", evt.info.parameters.page);
              };
              myVideo.addEventListener("cuePoint", listener);

              See the difference? In this movie, too, an lc instance is created.
              This time, instead of tracing the value of evt.info.parameters.page, we're
              using that value as the parameter that *this* lc instance sends. The event
              handler function invokes LocalConnection.send() on the lc instance of this
              movie. The first parameter is the connection name, the second is the method
              to call on the receiving end (yes, in quotes), and the third parameter
              passes along the value contained by this particuar cue point's custom page
              property.


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


              • 4. Re: Is there any way to use a Marker placed in an FLV to trigger a scripted page turn in a Flashpaper swf?
                mattcurylo Level 1
                David,
                This answer is amazing. I must admit I never expected anything as complete as this. And for that, I thank you!
                I am going to take this to the drawing board asap.

                Thanks again,
                Matt
                • 5. Re: Is there any way to use a Marker placed in an FLV to trigger a scripted page turn in a Flashpaper swf?
                  Level 7
                  Matt,

                  > This answer is amazing. I must admit I never expected anything
                  > as complete as this. And for that, I thank you!

                  haha ... I get teased sometimes about my "essay" replies. I do it when
                  I have time. Hope it steers you in the right direction.

                  > I am going to take this to the drawing board asap.

                  Sure thing. Come back if you have questions. My suggestion all hinges
                  on the expectation that the FlashPaper SWF is fully loaded by the time the
                  first cue point happens in the other movie's FLV. If you can't be sure of
                  this, you'll have to take steps to preload the SWF and not manipulated it
                  until it is loaded. The FlashPaper API at Adobe.com I linked to shows how
                  to make sure the FlashPaper SWF is loaded. I've tried using
                  MovieClipLoader, like they suggest, but interestingly (and befuddlingly), I
                  find that MovieClipLoader's onLoadInit event doesn't work with FlashPaper
                  the way it should. I use the alternate approach they suggest (the one with
                  setInterval()).


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