4 Replies Latest reply on Dec 7, 2006 10:03 AM by Newsgroup_User

    Flash button bar integration

    GoroLives?
      Hi there,

      I'm using flash MX2004 to create a navigation bar for a project in Director 8.5. I have used the getURL command in Flash to transfer information to Director. The buttons are names button1, button2 etc. I have put the flash component in Director and tested that it is recieving variable button names successfully.

      I want the button bar to change the director movie depending on what button is pressed. I am able to have the buttons jump to marker but not change movie.

      I'm also trying to implement a roll-over information feature ie. when the user rolls the mouse over a Flash button from Director, a text box in Director displays information, eg. When the user rolls over the "home" button, the information box reads "This button takes you to the first page".

      I'm pretty new to Director and randomly scouring the Lingo help doesn't seem to be helping me :)

      If anyone has any tips or solutions for my problems it would be much appreciated.

      Thanks in advance,
      GL
        • 1. Flash button bar integration
          duckets Level 1
          There's three different ways you can use 'geturl' to pass information or actions to lingo.

          1) using 'lingo:' allows you to call any single line of lingo from flash:

          getURL("lingo: <any lingo command>")

          examples:

          getURL("lingo: go to frame 20");
          getURL("lingo: go to movie \"nextMovie\"");
          getURL("lingo: alert(\"hello!\")");



          2) using 'event:' allows you to call any custom handler on a behaviour which is placed on

          the flash sprite in director.


          getURL("event: <custom behaviour handler name>")

          OR

          getURL("event: <custom behaviour handler name>, <param to pass>")


          Eg:
          In director (in a behaviour on the flash sprite):

          on flashMouseOver me
          beep
          end


          ... and in flash:

          getURL("event:flashMouseOver")


          Another example, when passing a parameter:

          In Director:

          on showMyName me,nameString
          member("name field").text = nameString
          end

          ... and in flash:

          getURL("event:showMyName,\"Ben\"");

          or even...

          getURL("event:showMyName,\""+username+"\"");



          3) using any string allows you to pass any string to director. To use this, you must

          create a movieScript handler called 'getURL' in director. Eg:

          In Director:

          on getURL tString
          alert("received: "&tString)
          end


          In Flash:

          getURL("this message will be received!");


          Any string then passed with 'getURL' from flash will be received by the getURL handler.



          ------------------------------------------------------------------------

          In all cases where quotes need to be included within the line of lingo, they must be

          escaped, which can lead to confusing looking collections of quote marks because the whole

          'URL' must be included in quotes too. Therefore, the lingo line:

          go to frame "foo"

          needs to be changed to:

          go to frame \"foo\"

          And finally when written as the getURL string, it should look like this:

          getURL("lingo: go to frame \"foo\"");



          - Ben
          • 2. Re: Flash button bar integration
            Level 7
            The getURL (stringFromFlash) method can be used in a behavior as well as
            a movie script.

            --
            Rob
            _______
            Rob Dillon
            Adobe Community Expert
            http://www.ddg-designs.com
            412-243-9119

            http://www.macromedia.com/software/trial/
            • 3. Re: Flash button bar integration
              Level 7
              It sounds like you want to have a number of different results from these
              flash button events. It also sounds like you have a number of buttons in
              the flash sprite.

              As duckets said, you can use the getURL() actionscript method to send
              information to Director, either to a behavior attached to the flash
              sprite or to a movie script.

              Director can interpret a mouse event on the Flash sprite, but it can't
              tell which object inside the flash sprite has been effected. In other
              words Director knows that the cursor rolled over the sprite, just not
              which clip or button was specifically rolled over.

              You will need to set up a strategy for working with these flash buttons.
              You will need to decide how much information to send to Director and
              when to send that information.

              Actionscript has rollover and rollout events as well as mouseDown and
              mouseUp events. So one way to deal with this is to use the individual
              rollover and rollout events to send information about the text display.
              Then use the mouseup event for navigation control.

              One way to simplify the work on the Flash end is to name each button
              instance. Then on the rollover, rollout and mouseup events, send the
              name of the button instance to Director. You can then use a simple case
              statement to parse out the button's instance name and use that name to
              tell Director what to do.

              In flash, name your buttons, it could be as simple as "one", "two", etc.
              The write a series of functions for those buttons. Maybe something like
              this:

              -----------------
              -- create an array to hold the names of all of the buttons...
              var buttonArray:Array = new Array(one,two,three,four);

              -- create a set of functions for these buttons...
              for (i in buttonArray) {
              buttonArray .onRollOver = sendRollOver;
              buttonArray
              .onRollOut = sendRollOut;
              buttonArray .onMouseUp = sendMouseUp;
              }

              -- for the rollover event, send a string that contains a key word and
              the button name...
              function sendRollOver() {
              var stringToSend:String = "roll$"+ parseButtonName(this);
              getURL(stringToSend);
              }

              -- do similar for the mouseUp event...
              function sendMouseUp() {
              var stringToSend:String = "up$"+ parseButtonName(this);
              getURL(stringToSend);
              }

              -- for the rollout event just send a simple string...
              function sendRollOut() {
              getURL("rollout");
              }

              -- this function will strip out the simple button instance name from its
              full path...
              function parseButtonName(button) {
              var buttonName:String = string(button);
              var nameParts:Array = buttonName.split(".");
              var shortName = nameParts[nameParts.length -1];
              return shortName;
              }

              --------------

              Now you have a very simple flash movie that doesn't need to be edited
              every time something changes in the Director movie.

              in Director make a behavior that will sit on the Flash sprite:

              --------------

              property thisSprite

              on beginSprite me
              thisSprite = me.spriteNum
              end

              on getURL me,data
              if data = "rollout" then
              member("text display member").text = ""
              else
              parseOut(data)
              end if
              end

              on parseOut(thisString)
              oldDelim = the itemDelimiter
              the itemDelimiter = "$"
              if thisString.item[1] = "roll" then
              case (thisString.item[2]) of
              "one": member("text display member").text =
              "first button string"
              "two": member("text display member").text =
              "second button string"
              -- continue as needed
              end case
              if thisString.item[1] = "up" then
              case (thisString.item[2]) of
              -- similar to above
              end case
              end if
              the itemDelimiter = oldDelim
              end
              -----------------

              --
              Rob
              _______
              Rob Dillon
              Adobe Community Expert
              http://www.ddg-designs.com
              412-243-9119

              http://www.macromedia.com/software/trial/
              • 4. Re: Flash button bar integration
                Level 7
                On Thu, 07 Dec 2006 12:56:14 GMT, GoroLives? posted in
                macromedia.director.lingo:

                > I'm using flash MX2004 to create a navigation bar for a project in
                > Director 8.5.

                Don't forget that D8.5 only supports Flash 5 and below.

                You may have to avoid using any AS2.0 code.


                --
                Mark A. Boyd
                Keep-On-Learnin' :)