1 Reply Latest reply on Oct 28, 2011 2:23 PM by Adam-C

    How can i communicate xml with lingo?

    Igor R. Gomes Level 1

      I create a menu in flash that communicate with director, and use this code..

       

       

      on (release) {

                  //Goto Webpage Behavior

                getURL("lingo: set the Filename of member \"container\" to \"pg/54.pdf\" ");

                //End Behavior

      }

      And this works fine...

      But bow, i create a better menu that uses xml, and i dont know how comunicate the menu with director.

       

      Anyone can help me?

      The code of my xml is simple..

      <FILE NAME="GO TO" LINK="my lingo code" />

        • 1. Re: How can i communicate xml with lingo?
          Adam-C Level 2

          Personally I wouldn't bother using XML to send such a small message to Director from Flash. I construct a string in Flash that can then be converted to to a propList in Director using a "do" command, and then handled by a case block. For example:

           

          IN FLASH:

          function sendAMessageToDirector() {

               var theMessage:Text = '[#buttonClicked: #' + this.buttonId + ']';

               getURL(theMessage);

          }

           

          IN DIRECTOR BEHAVIOR SCRIPT ATTACHED TO THE FLASH SPRITE

          on getURL me, flashString

               flashData = void

               do "flashData =" && flashString

               case flashData.getPropAt(1) of   

                    #buttonClicked:

                         put "the button clicked was " & flashData[1]

                    #anotherMessage:

                         --etc.

               end case

          end

           

          To do what you ask with XML:

           

          IN FLASH

          on (release) {

               getURL('<FILE NAME="GO TO" LINK="myLingoCode" />');

          }

           

          IN DIRECTOR BEHAVIOUR ATTACHED TO FLASH SPRITE

          on getURL me, xmlString

               xmlParser = new xtra("xmlparser")

               xmlParser.parseString(xmlString)

               xmlPropList = xmlParser.makeList()

               case xmlPropList[1]["FILE"]["!ATTRIBUTES"]["NAME"] of

                    "GO TO":

                     do xmlPropList[1]["FILE"]["!ATTRIBUTES"]["LINK"]

               end case

          end

           

          To understand this script you may need to study the way the XML data structure converts into a propList data structure via Director's XML Parser. Also, pay close attention to the way I've used single and double quotes within Flash.

           

          BTW - just a suggestion - but I don't advise you use capitals for your XML tag names - much better to use lower case so you can use upper-case to denote the start of a word in the tag-name. For example "<myTag>" is much more readable than "<MYTAG>"

          1 person found this helpful