RE: [flexcoders] AMFPHP / databinding nested arrays

2006-12-06 Thread dj
The way you constructed your array might come out like this, but not
sure, looks a little crazy…


myResultObject[0].day.mon.start.100.end.300


Nested Arrays return into Flex as objects.  I haven’t tried nesting
an array as complicated as this, I guess it’s doable – but it
might be better to reorganize your array structure .  I think it will
be easier to read than a big old nested array constructor than in php
if you use the following example, and this is how I do it.


?
$my_array = array();
$my_array[0]['days'] =$some array
$my_array[0]['starts'] =$some_other_array
Return $my_array;
?


//in flex your result arrays work like this...

Var someArray:Array  = myResultObject[0].days
Var someOtherArray:Array  = myResultObject[0].starts


Then you can get your values and organize your arrays which ever way
you like.

Hope this Helps

Patrick

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]
On Behalf Of carkraus
Sent: Tuesday, December 05, 2006 11:19 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] AMFPHP / databinding nested arrays

Hi there,

I guess this is a typical newbie question,  maybe someone could
kindly direct me to a tutorial or sample:

I try to bind e.g. using a charts control to a nested array I receive
from an AMFPHP service.
On the php side I have as an example:
$outputArr[] = array('day' = 'Mon', array('start' = '100', 'end' =
'300'));
$outputArr[] = array('day' = 'Tue', array('start' = '250', 'end' =
'600'));
$outputArr[] = array('day' = 'Wed', array('start' = '500', 'end' =
'600'));
return $outputArr;
..which will deliver the data correctly as I can see from the flex
debugger.

In flex I have eg.:
mx:series
mx:ColumnSeries xField=day yField=??? /
/mx:series
Now, how do I access e.g. the value 'start' to use it for
databinding? Well, 'day.start' does not do the trick : )

I had similar probs using XML for binding, where I wouldnt be able to
access sub-children?
Do I have to somehow wrap the server response into an actionscript
object which I'd have to manually add properties to?

Any hint greatly appreciated!!
carsten

 




Re: [flexcoders] AMFPHP / databinding nested arrays

2006-12-05 Thread Patrick Mineault
Hmmm, why exactly are you sending nested arrays from amfphp? Why can't 
you just send a flat array?

Patrick

carkraus a écrit :

 Hi there,

 I guess this is a typical newbie question,  maybe someone could kindly 
 direct me to a tutorial or sample:

 I try to bind e.g. using a charts control to a nested array I receive 
 from an AMFPHP service.
 On the php side I have as an example:

 $outputArr[] = array('day' = 'Mon', array('start' = '100', 'end'
 = '300'));
 $outputArr[] = array('day' = 'Tue', array('start' = '250', 'end'
 = '600'));
 $outputArr[] = array('day' = 'Wed', array('start' = '500', 'end'
 = '600'));
 return $outputArr;

 ..which will deliver the data correctly as I can see from the flex 
 debugger.

 In flex I have eg.:

 mx:series
 mx:ColumnSeries xField=day yField=??? /
 /mx:series

 Now, how do I access e.g. the value 'start' to use it for databinding? 
 Well, 'day.start' does not do the trick : )

 I had similar probs using XML for binding, where I wouldnt be able to 
 access sub-children?
 Do I have to somehow wrap the server response into an actionscript 
 object which I'd have to manually add properties to?

 Any hint greatly appreciated! !
 carsten