+ Reply to Thread
Results 1 to 3 of 3

Thread: How do you get the *element name* from an AS3 array?

  1. Join Date
    Oct 2009
    Posts
    2

    How do you get the *element name* from an AS3 array?

    I have a class in my AMFPHP services which returns an associative array, but I am unable to get the actual names of the array elements inside of flash, even though the element names will show up in the service browser.

    For example, if I construct a "pet" array in PHP like so...

    $this_pet=array();
    $this_pet["type"]="cat";
    $this_pet["color"]="black";
    $this_pet["hair"]="fluffy";
    return($this_pet);

    ...So the data format basically is:

    element[key]=value

    When I call the service from AS3, I can only get the values, but not the names of each element.


    for (var i in responds) {
    trace(responds[i])
    }


    ...so I can get the value, but how do I get the actual name of the *element*?
    Last edited by samblue; 8th October 2009 at 16:21.

  2. Join Date
    Apr 2006
    Location
    Travedona Monate, Varese
    Age
    36
    Posts
    91
    did you try with:

    for (var i in responds) {
    trace(i)
    }
    Alessandro Crugnola
    Flash|iPhone|Python developer

    Alittleb.it
    Aviary.com
    Macromedia Team Volunteer

  3. Join Date
    Oct 2009
    Posts
    2
    Wow. Thank you! That is so simple and so obscure at the same time. It worked perfectly.

    Is this the only way to get the name of a key when we have

    element[key]=value?

    or are there other array-access operators that can also do this?

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts