4 Replies Latest reply on Sep 27, 2010 3:26 PM by TimDixon

    passing flash array to flash sprite

    FlashGodThe2nd

      Hi,

       

      I am trying to pass a flash array like [{x:1,y:2},{x:1,y:2},{x:3,y:5}] from a flash sprite to Director lingo and back to another flash sprite. In director all looks fine when passing it back to the second sprite but the flash trace command just gives me undefined values. Can't I do this in lingo?

       

      in lingo:

          put " flashAry.length " &  flashAry.length

          flashObject.DrawAry(flashAry,"testxy")

       

      Output window:

      -- " flashAry.length 23.0000"

       

       

      in ActionScript

          function DrawAry(points:Array,test){
          trace(">DrawAry " + points + " " + points.length + " >" + test + "<")

       

      Output window:

      -- >DrawAry undefined undefined >testxy<

        • 1. Re: passing flash array to flash sprite
          Sean_Wilson Adobe Community Professional

          It's not clear how you are passing data around, but you should use the Flash xtra's convert() method to translate the initial array into a Lingo list and then convert() again the list back to an array when you pass it to the second sprite.

           

          See this article for more details.

           

          edit: added URL

          1 person found this helpful
          • 2. Re: passing flash array to flash sprite
            Sean_Wilson Adobe Community Professional

            Alternatively, you could set up a LocalConnection between the 2 sprites (assuming they exist simultaneously on your stage) and pass data over this.

            • 3. Re: passing flash array to flash sprite
              FlashGodThe2nd Level 1

              I was passing an array (with object elements) from a Flash sprite to Director and sending it by sendallsprites to the same member on a different sprite to draw something.

               

              I have to take a look at the 'convert' command. I did think about the local connect but decided to make a string conversion in Flash and pass it through Director.

               

              Thanks for your solutions!

              • 4. Re: passing flash array to flash sprite
                TimDixon

                Had a very similar problem and found a solution...

                 

                Hope this helps....

                 

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

                -- This GETS an array from Flash to Director

                -- 'myFlashArray' is the name of the array in your Flash file

                -- 'flaArray' is the new list created in Director

                -- And obviously, the flash file is on sprite 1

                 

                  flaArray = convert(#list, sprite(1).myFlashArray)

                  put flaArray

                 

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

                -- This SENDS a Director list to flash (as an array)

                -- 'zz' is just a temporary variable so the script is easier to read

                -- 'dirList' is your Director List

                -- 'myNewFlashArray' is the name of the newly created array in your flash file

                -- again, the flash file is on sprite 1 in this case

                 

                 

                  dirList = ["item 1","item 2","item 3"]

                  zz = convert(#flashObjectArray, dirList).toString()

                  sprite(1).createVariable(#myNewFlashArray, zz )

                 

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

                 

                NOTE: I'm using an undocumented 'convert' function that is only available in Director 10.1.1 onwards...