Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 17:58
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash 8 (Moderators: Jorge Solis, ..:: Mazhar Hasan ::.., Andresss)
| | |-+  Assigning array to associative array
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Assigning array to associative array  (Read 872 times)
neatgadgets
Server what's that
*
Posts: 17


View Profile Email
« on: 08/31/10, 17:42 »

Hi,

I have an associative array, but the values maybe string, number or array. I have no problem assigning strings or numbers to the associative array, but how do I add an array to the associative array? I have just tried somehting like this but it doesn't work:

assoc_array["sample_id"] = [{label:"a", data:"1"}, {label:"b", data:"2"}, {label:"c", data:"3"}]
« Last Edit: 08/31/10, 18:05 by neatgadgets » Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #1 on: 09/01/10, 06:46 »

Code:
assoc_array["sample_id"] = array({label:"a", data:"1"}, {label:"b", data:"2"}, {label:"c", data:"3"});
Logged

happy flashing
Cool
Ronald
neatgadgets
Server what's that
*
Posts: 17


View Profile Email
« Reply #2 on: 09/01/10, 17:27 »

Thanks. Now if I want to trace to see the values are being set properly how would I format the trace?

e.g.
trace(assoc_array["sample_id"]][1]);
trace(assoc_array["sample_id"]][2]);

Obviously this doesn't work but I just did this to give you the idea of what I am trying to do.

Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #3 on: 09/02/10, 01:58 »

brackets of any kind should allways be in pairs:
Code:
trace(assoc_array["sample_id"][1]);
should do it.
But then you receive just another array Wink
Code:
trace(assoc_array["sample_id"][1]["label"]);
should give you the label of the second inner element (arrays allways count from zero).
Logged

happy flashing
Cool
Ronald
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!