You can get back the plain Array by doing:

var aRoster:Array = rosterInfo.source;

 

Now, what you are doing is a bit odd.  You are looping over an XMLList
to build an ArrayCollection of XML nodes.  Do you have a reason for
this, instead of just using XMLListCollection? You would not need to
loop to do this.  

 

There are performance benefits to building an ArrayCollection from XML,
but it requires strongly typed objects to get the benefit, and using XML
will not help with that.

 

If you are asking how to update a database from a Flex client, that is a
very large and general subject.  You'd best ask it under its own
subject.

 

But the method you choose to do this will impact the way you handle the
data in Flex (ArrayCollection vs XMLListCollection vs XML), so you
should make those choices before you go much further with your client
implementation.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of mr_delphi_developer
Sent: Friday, May 09, 2008 10:42 AM
To: [email protected]
Subject: [flexcoders] Re: Using XMLList as dataprovider to DataGrid and
Adding rows

 

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Right. That's too much code to analyze, but generally, if you plan 
> to update a dataProvider programatically, do not use XMLList or 
> Array,as they do not dispatch the necessary events to update the 
> UI. With XML, use XMLListCollection, then use that api to update 
> the data. All should work as expected.
> 
> 
> 
> Tracy
> 
> 
<SNIP>

OK here is the modification, I added three fields and another
button to allow adding of players to the ArrayCollection.

This works exactly as needed but how do I send changes to the 
ArrayCollection back to a PHP script so I may modify my DB? 
If I send the ArrayCollection, how will it be seen by the PHP 
script, as an array?

[Bindable]
private var rosterInfo:ArrayCollection = new ArrayCollection();

public function handleXML(event:ResultEvent):void
{
// Convert XML response to ArrayCollection
for each(var s:XML in event.result.option){
rosterInfo.addItem(s);
}
}

<snip>

// This function adds rows to the ArrayCollection, clears the
// entry controls and scrolls the newest entry into view.
public function addPlayer():void
{
if ((player_name.text.length > 0) ||
(jersey_.text.length > 0)) ||
(age_.text.length > 0))
{
(RosterList.dataProvider as ArrayCollection).addItem(
{playerid: 0, 
playername: player_name.text, 
jersey: jersey_.text, 
age: age_.text}
);
player_name.text = '';
jersey_.text = '';
age_.text = '';
RosterList.selectedIndex = rosterInfo.length;
RosterList.scrollToIndex(RosterList.selectedIndex);
} else {
Alert.show("Players may be entered with blank values");
}
}

 

Reply via email to