I receive from the httpservice with a certain frequency a string like this:
1#3#234525234
where
row#column#value
I want to display into datagrid the above string at real time; at the moment my code displays the whole string, composed by many strings like the one above.
How can i solve the problem?
Thanks in advance
I have the following code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns="*" creationComplete="srv.send()" >
<mx:Script>
<![CDATA[
import mx.effects.effectClasses.AddItemActionInstance;
import mx.effects.AddItemAction;
import mx.collections.ArrayCollection;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.events.*;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.InvokeEvent;
import mx.rpc.events.FaultEvent;
import mx.rpc.AsyncRequest;
import mx.rpc.AsyncResponder;
import mx.rpc.AsyncToken;
import mx.rpc.AbstractInvoker;
import mx.controls.Alert;
import mx.core.Container;
import mx.core.IDataRenderer;
import mx.controls.dataGridClasses.DataGridItemRenderer;
import mx.controls.DataGrid;
import flash.display.DisplayObject;
[Bindable]
public var i:Number;
public var source:String;
[Bindable]
public var row:Array;
public var column:Array;
public var value:Array;
public function cycle(source:String):void
{
var data:Array = source.split('#');
i=0;
for each(data in source)
{
row[i]=data[i]
column[i]=data[i+1]
value[i]=data[i+2]
i=i+3
}
}
]]>
</mx:Script>
<mx:HTTPService
id="srv"
url="http://10.15.20.75/server4flex/servlet/Datagen"
method="GET"
/>
<mx:TextArea text="{cycle(srv.lastResult.toString())}" x="10" y="50"
width="699" height="59"/>
<mx:AdvancedDataGrid dataProvider="{source}" liveScrolling="true" id="dg"
x="10" y="117" width="621">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="{row[i]}"
headerText="Riga"/>
<mx:AdvancedDataGridColumn dataField="{column[i]}"
headerText="Colonna"/>
<mx:AdvancedDataGridColumn dataField="{value[i]}"
headerText="Valore"/>
</mx:columns>
</mx:AdvancedDataGrid>
First of all, the loop seems to be wrong, you iterate over a string source, not an array.
Secondly, your grid should bind to some properties of objects stored in a dataProvider (Array, ArrayCollection, etc.). So the data provider shouldn't be a string, as in your code.
Thridly, dataField is the name of the field of the object stored in the dataProvider, which value should be displayed in the grid cell.
Basicly, you need to parse your incoming string, store each row in an object and store all these objects in a collection.
So, the code should be something like:
[Bindable]
private var dataList:ArrayCollection;
public function cycle(source:String):void
{
var ac:ArrayCollection = new ArrayCollection();
for(var i:int = 0; i < data.length; i += 3) {
var dataObj:Object = {row: data[i], column: data[i+1], value: data[i+2]};
ac.addItem(dataObj);
}
dataList = ac;
}
<mx:AdvancedDataGrid dataProvider="{dataList}" liveScrolling="true" id="dg"
x="10" y="117" width="621">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="row"
headerText="Riga"/>
<mx:AdvancedDataGridColumn dataField="column"
headerText="Colonna"/>
<mx:AdvancedDataGridColumn dataField="value"
headerText="Valore"/>
</mx:columns>
</mx:AdvancedDataGrid>
Related
I want to make an App using SplitViewNavigator container which contains List of cities in left view and Detail about the city in right view, In right view there is a text input through I get Name of city and store in a SQLite Database, and that name should be added to list in left view from SQLite Database I got started with flowing code in Main.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
applicationDPI="160"
initialize="application1_initializeHandler(event)">
<fx:Script>
<![CDATA[
import model.DataModel;
import mx.events.FlexEvent;
import valueobject.CityValueObject;
import utillities.CityUtils;
public var sqlConnection:SQLConnection;
protected var statement:SQLStatement;
protected function application1_initializeHandler(event:FlexEvent):void
{
sqlConnection = new SQLConnection();
sqlConnection.open(File.applicationStorageDirectory.resolvePath("cityDB.db"), SQLMode.CREATE);
statement.sqlConnection = sqlConnection; // Here error occurs saying that Error #1009: Cannot access a property or method of a null object reference.
statement.text = "CREATE TABLE IF NOT EXISTS CITYNAME (" +
"id INTEGER PRIMARY KEY AUTOINCREMENT, " +
"nameofcity TEXT)";
statement.execute();
DataModel.getInstance().connection = sqlConnection;
CityUtils.getAllCities();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:SplitViewNavigator id="svn" width="100%" height="100%">
<s:ViewNavigator width="30%" height="100%" id="list_of_cities" firstView="views.ListOfCities"/>
<s:ViewNavigator width="70%" height="100%" id="display_contents" firstView="views.DisplayContents"/>
</s:SplitViewNavigator>
My model.DataModel is an action script class:
package model
{
import flash.data.SQLConnection;
import mx.collections.ArrayCollection;
[Bindable]
public class DataModel
{
public var connection:SQLConnection;
public var cityList:ArrayCollection = new ArrayCollection();
public var logs:String="Application Logs........\n";
public static var _instance:DataModel;
public function DataModel()
{
}
public static function getInstance():DataModel
{
if(_instance == null)
{
_instance = new DataModel();
}
return _instance;
}
}
}
My valueobject.CityValueObject class is:
package valueobject
{
[Bindable]
public class CityValueObject
{
public var id:uint;
public var nameofcity:String;
}}
And My uttillities.CityUtils class is ::
package utillities
{
import flash.data.SQLResult;
import flash.data.SQLStatement;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.net.URLRequest;
import flash.utils.ByteArray;
import model.DataModel;
import mx.collections.Sort;
import mx.collections.SortField;
import valueobject.CityValueObject;
public class CityUtils
{
public static function getAllCities():void
{
var contactListStatement:SQLStatement = new SQLStatement();
contactListStatement.sqlConnection = DataModel.getInstance().connection;
contactListStatement.text = "SELECT * FROM CITYNAME";
contactListStatement.execute();
var result:SQLResult = contactListStatement.getResult();
if( result.data!=null)
{
DataModel.getInstance().cityList.removeAll();
for(var count:uint=0;count<result.data.length;count++)
{
var cityVO:CityValueObject = new CityValueObject();
cityVO.id = result.data[count].id;
cityVO.nameofcity = result.data[count].city;
DataModel.getInstance().cityList.addItem(cityVO);
}
}
sortData();
}
public static function sortData():void
{
var dataSortField:SortField = new SortField();
dataSortField.name = "cityName";
dataSortField.numeric = false;
/* Create the Sort object and add the SortField object created earlier to the array of fields to sort on. */
var numericDataSort:Sort = new Sort();
numericDataSort.fields = [dataSortField];
/* Set the ArrayCollection object's sort property to our custom sort, and refresh the ArrayCollection. */
DataModel.getInstance().cityList.sort = numericDataSort;
DataModel.getInstance().cityList.refresh();
}
public static function updateLog(newLog:String):void
{
DataModel.getInstance().logs += new Date().time+" :-> "+newLog+"\n";
}
}
}
My left containing list of cities is :
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Cities"
>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import model.DataModel;
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import mx.events.IndexChangedEvent;
import spark.components.SplitViewNavigator;
import spark.components.ViewNavigator;
import spark.transitions.ViewTransitionBase;
protected function myList_changeHandler():void {
// Create a reference to the SplitViewNavigator.
var splitNavigator:SplitViewNavigator = navigator.parentNavigator as SplitViewNavigator;
// Create a reference to the ViewNavigator for the Detail frame.
var detailNavigator:ViewNavigator = splitNavigator.getViewNavigatorAt(1) as ViewNavigator;
detailNavigator.transitionsEnabled = false;
// Change the view of the Detail frame based on the selected List item.
detailNavigator.pushView(DisplayContents, list_of_cities.selectedItem);
}
]]>
</fx:Script>
<s:VGroup width="100%" height="100%">
<s:List id="list_of_cities" height="100%" width="100%" change="myList_changeHandler();"
dataProvider="{DataModel.getInstance().cityList}" labelField="nameofcity">
</s:List>
</s:VGroup>
and in last my Display Detail about city is simply like this :
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Detail About City"
>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:actionContent>
<s:CalloutButton id="add_call_out_button" label="Add City" verticalPosition="after"
icon="#Embed('assets/add.png')" calloutDestructionPolicy="never">
<!-- layout the callout content here -->
<s:calloutLayout>
<s:VerticalLayout paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10" horizontalAlign="center" gap="5"/>
</s:calloutLayout>
<s:calloutContent>
<s:TextInput id="city_name_input" prompt="Enter City Name" text="Sydney"/>
<s:HGroup gap="40">
<s:Button id="add_city_name" label="Add City" width="150" height="40" click="add_city_name_clickHandler()"/>
<s:CheckBox id="preferred_cbox" label="Preferred" height="40" />
</s:HGroup>
</s:calloutContent>
</s:CalloutButton>
<s:Button id="remove_city_name" label="Remove" width="120" height="40"
click="remove_city_name_clickHandler()" icon="#Embed('assets/delete.png')"/>
</s:actionContent>
<s:Label id="nameSomeThing" text="{data.Description}"/>
<fx:Script>
<![CDATA[
import model.DataModel;
import spark.components.SplitViewNavigator;
import spark.components.ViewNavigator;
protected function add_city_name_clickHandler():void
{
var sqlStatement:SQLStatement = new SQLStatement();
sqlStatement.sqlConnection = DataModel.getInstance().connection;
sqlStatement.text = "INSERT INTO CITYNAME (nameofcity)" +
"VALUES(:nameofcity)";
sqlStatement.parameters[":nameofcity"] = city_name_input.text;
sqlStatement.execute();
var splitNavigator:SplitViewNavigator = navigator.parentNavigator as SplitViewNavigator;
// Create a reference to the ViewNavigator for the Detail frame.
var detailNavigator:ViewNavigator = splitNavigator.getViewNavigatorAt(1) as ViewNavigator;
detailNavigator.transitionsEnabled = false;
// Change the view of the Detail frame based on the selected List item.
detailNavigator.popToFirstView();
}
protected function remove_city_name_clickHandler():void
{
// TODO Auto-generated method stub
}
]]>
</fx:Script>
the above view(Display Detail) is still in development but at this stage I was Trying to add City Name to list of cities by getting name from city name input text input but at:
statement.sqlConnection = sqlConnection; // Here error occurs saying that Error #1009: Cannot access a property or method of a null object reference.
Iget that error and not be able to go ahead.
Can any one please give me the way to solve my this problem by my code givien above or suggest me an other way to meet my needs by this App Thanks in Advance...
As the error message says, statement is null.
I don't see any code that would initialize it.
You need:
statement = new SQLStament();
(And I don't see any reason why this variable would need to be outside the application1_initializeHandler function.)
Gallery in DataGroup, How can i Call selected image(MouseClick Image) this is my Sample code
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.managers.PopUpManager;
import spark.components.Image;
import spark.components.TitleWindow;
[Bindable]
private var myArray:ArrayCollection= new ArrayCollection([
{image:'Assets/images/best_01.jpg'},
{image:'Assets/images/best_02.jpg'},
{image:'Assets/images/best_03.jpg'},
{image:'Assets/images/best_04.jpg'}]);
private function imageClickHandler(event:MouseEvent):void {
var imgCount:Number=0;
var image:Image= new Image();
PopUpManager.addPopUp(image,this,true);
image.source=myArray.getItemAt(imgCount).image;
}
]]>
</fx:Script>
<s:DataGroup id="dg" itemRenderer="com.ItemRenderForHorizontallist"
dataProvider="{myArray}"
verticalCenter="0"
horizontalCenter="0"
click="imageClickHandler(event)">
<s:layout >
<s:TileLayout horizontalGap="20" verticalGap="20" columnWidth="180" />
</s:layout>
</s:DataGroup>
this code work but i want selected image(MouseClick Image) any one help me ............ thanks*
You're using imgCount to access the index of your ArrayCollection; however, you always set it to 0.
You could change s:DataGroup to s:List, then use the selectedItem property in your click handler:
image.source = dg.selectedItem["image"];
I am trying to place an image besides the label in y-axis. So I have created a custom label renderer(A HBox containing and ). The source for the image has to be set based on a property present in the data provider. The problem is, I am not able to access the BarSeriesItem in the fnSetSource() method. Any help or pointers is greatly appreciated.
Here's the entire code.
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
width="1280" height="750">
<mx:Script><![CDATA[
import mx.collections.ArrayCollection;
import mx.charts.series.items.PlotSeriesItem;
import mx.controls.Label;
import mx.controls.Image;
import mx.containers.HBox;
import mx.charts.series.items.BarSeriesItem;
import mx.charts.series.ColumnSeries;
import mx.charts.series.items.ColumnSeriesItem;
import mx.charts.chartClasses.Series;
import mx.charts.ChartItem;
[Bindable]
public var employeedetails:ArrayCollection = new ArrayCollection([
{rank:"10",emplName:"Peter",prevRank:"7",imgSource:"images/increase.png"},
{rank:"9",emplName:"Mark",prevRank:"3",imgSource:"images/decrease.png"},
{rank:"8",emplName:"Eric",prevRank:"8",imgSource:"images/decrease.png"}
]);
]]>
</mx:Script>
<mx:BarChart id="bar" height="100%"
paddingLeft="15" paddingRight="5"
showDataTips="true" width="847"
dataTipMode="multiple" >
<mx:verticalAxis>
<mx:CategoryAxis id="v1" categoryField="emplName" dataProvider="{employeedetails}"/>
</mx:verticalAxis>
<mx:verticalAxisRenderers>
<mx:AxisRenderer placement="left" axis="{v1}">
<mx:labelRenderer>
<mx:Component>
<mx:HBox width="100%" height="100%" minWidth="120" minHeight="20">
<mx:Image id="axisImage" height="16" width="16" source="fnSetSource()">
<mx:Script><![CDATA[
import mx.charts.chartClasses.Series;
import mx.charts.ChartItem;
import mx.charts.series.items.BarSeriesItem;
[Bindable]
public function fnSetSource(element : ChartItem, series : Series) : String
{
var data : BarSeriesItem = BarSeriesItem(element);
var imgSrc : String = "";
if (data.item.isIncrease)
{
imgSrc = "images/increase.png";
} else if (data.item.isDecrease)
{
imgSrc = "images/decrease.png";
}
else
{
imgSrc = "";
}
return imgSrc;
}
]]></mx:Script>
</mx:Image>
<mx:Label id="axisLabel" fontSize="12" width="100%" height="100%">
<mx:Script><![CDATA[
[Bindable]
override public function set data(value : Object) : void
{
if (value == null)
{
return;
}
var length : int = value.text.toString().length;
if (length > 15)
{
axisLabel.text = value.text.toString().substr(0, 15) + "...";
axisLabel.toolTip = value.text;
}
else
{
axisLabel.text = value.text;
}
}
]]>
</mx:Script>
</mx:Label>
</mx:HBox>
</mx:Component>
</mx:labelRenderer>
</mx:AxisRenderer>
</mx:verticalAxisRenderers>
<mx:series>
<mx:BarSeries id="bs2"
yField="emplName"
xField="rank"
displayName="Rank"
dataProvider="{employeedetails}"
/>
</mx:series>
</mx:BarChart>
</mx:Application>
I had a quick look at the code. The fnSetSource() function will not be called until it is placed inside curly brackets: source="{fnSetSource()}"
This will get the function to be called, but you will get errors because the fnSetSource() call does not have the 2 parameters that fnSetSource function requires. Make the first change I mentioned and you may be able to figure it out from there.
Could you not make an item renderer that is a seperate mxml component?
look like you are not passing any parameters that fnSetSource() needs so it will not work untill you pass those two parameters..
use your function this way
fnSetSource(value:Object,previousValue:Object,axis:IAxis):String
I know how to drag from list and drop into the textinput control. But I don't know how to insert the text in textinput under the position of the cursor. For example, I have text qwerty in textinput. And I need to drop the word asdf in the textinput. As a result I want to get text qweasdfrty or qasdfwerty, or whatever I want depending on the cursor position.
Here is the simplified code of what I already have:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
layout="absolute"
minWidth="955"
minHeight="600">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private function init():void
{
horList.dataProvider=new ArrayCollection(["Reading", "Television", "Movies"]);
}
import mx.managers.DragManager;
import mx.core.DragSource;
import mx.events.DragEvent;
import flash.events.MouseEvent;
private function dragEnterHandler(event:DragEvent):void {
if (event.dragSource.hasFormat("items"))
DragManager.acceptDragDrop(TextInput(event.currentTarget));
}
private function dragOverHandler(event:DragEvent):void
{
if (event.dragSource.hasFormat("items"))
DragManager.showFeedback(DragManager.COPY);
}
private function dragDropHandler(event:DragEvent):void {
if (event.dragSource.hasFormat("items"))
{
var draggedText:Array = event.dragSource.dataForFormat("items") as Array;
var textInput : TextInput = TextInput(event.currentTarget);
// here i want to insert the text from (draggedText[0] as String) into textInput
}
}
]]>
</fx:Script>
<mx:HorizontalList id="horList"
x="10"
y="10"
width="625"
dragEnabled="true"
creationComplete="init()">
</mx:HorizontalList>
<mx:TextInput id="destTextInput"
x="100"
y="117"
dragEnter="dragEnterHandler(event);"
dragOver="dragOverHandler(event);"
dragDrop="dragDropHandler(event);"/>
</mx:Application>
Is there any ways to achieve this?
Here is a full example. It required access to the mx_internal namespace unfortunately but should hold up fine. The reason it had to use mx_internal is to get access to the IUITextField reference.
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.core.IUITextField;
//Note use of mx_internal namespace
import mx.core.mx_internal;
use namespace mx_internal;
private function init():void
{
horList.dataProvider=new ArrayCollection(["Reading", "Television", "Movies"]);
}
import mx.managers.DragManager;
import mx.core.DragSource;
import mx.events.DragEvent;
import flash.events.MouseEvent;
private function dragEnterHandler(event:DragEvent):void {
if (event.dragSource.hasFormat("items"))
DragManager.acceptDragDrop(TextInput(event.currentTarget));
}
private function dragOverHandler(event:DragEvent):void
{
if (event.dragSource.hasFormat("items"))
DragManager.showFeedback(DragManager.COPY);
}
private function dragDropHandler(event:DragEvent):void {
if (event.dragSource.hasFormat("items"))
{
var draggedText:Array = event.dragSource.dataForFormat("items") as Array;
var textInput : TextInput = TextInput(event.currentTarget);
// here i want to insert the text from (draggedText[0] as String) into textInput
//Using mx_internal namespace to gain access to internal textfield
var tf:IUITextField = textInput.getTextField();
var charIndex:int = tf.getCharIndexAtPoint(textInput.contentMouseX, textInput.contentMouseY);
//dropped after end of text
if(charIndex == -1 && mouseX > tf.textWidth)
{
tf.appendText(draggedText[0]);
}
//Dropped at beginning of field (only happens when it is empty)
else if(charIndex == -1 && mouseX < tf.textWidth)
{
tf.text = draggedText[0];
}
//dropped inline to text
else
{
tf.replaceText(charIndex, charIndex, draggedText[0]);
}
}
}
]]>
</fx:Script>
<mx:HorizontalList id="horList"
x="10"
y="10"
width="625"
dragEnabled="true"
creationComplete="init()">
</mx:HorizontalList>
<mx:TextInput id="destTextInput"
x="100"
y="117"
dragEnter="dragEnterHandler(event);"
dragOver="dragOverHandler(event);"
dragDrop="dragDropHandler(event);"/>
I am trying my first flex application. And have a problems adding data from xml http service to datagid.
My xml file looks like this:
<players>
<player>
<name>test</name>
<status>F</status>
<claimed>1</claimed>
</player>
<player>
<name>meta</name>
<status>F</status>
<claimed>1</claimed>
</player>
</players>
First I tried to fill the data in a raw way, so created mxml tag for HTTP service, and added handlers.
But very soon I realized that main application file became unreadable (because of huge amount of code), so I decided to organize it some way.
So decided to replace services with a separate as classes.
My new code looks like this:
MXML:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" creationComplete="main()" height="756" borderColor="#FFFFFF" width="950" top="10" left="10" horizontalAlign="left" verticalAlign="top" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FCFCFC, #FCFCFC]">
<mx:Panel width="900" height="727" layout="absolute" title="Игра ГО" horizontalAlign="center" horizontalCenter="0" top="10">
<mx:Script>
<![CDATA[
import goclient.ListOfPlayers;
import goclient.usersList;
import goclient.Tester;
import mx.controls.Alert;
// And makes periodical requests to the server
[Bindable]
public var users:ListOfPlayers;
[Bindable]
public var test:Tester;
public function main():void{
test = new Tester();
users = new ListOfPlayers();
}
]]>
</mx:Script>
<mx:DataGrid doubleClickEnabled="true" dataProvider="{users.getPlayersList()}"
x="10" y="157" width="860" height="520" id="userList">
<mx:columns>
<mx:DataGridColumn dataField="claimed" headerText="Was claimed" width="25"/>
<mx:DataGridColumn dataField="name" headerText="Name of the player" />
<mx:DataGridColumn dataField="status" headerText="Status (Free or Busy)" />
</mx:columns>
</mx:DataGrid>
And the service class:
ListOfPlayers.as
package goclient
{
import flash.utils.Timer;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.mxml.HTTPService;
public class ListOfPlayers
{
public var usersListService:HTTPService;
private var minTimer:Timer = new Timer(100000, 0);
private var playersData:ArrayCollection;
private var person:currentPerson;
public function ListOfPlayers()
{
usersListService = new HTTPService();
usersListService.url = "http://127.0.0.1:8000/go/active/";
usersListService.addEventListener(ResultEvent.RESULT, resultHandler);
//Alert.show("Here");
sendData();
//minTimer.addEventListener(TimerEvent.TIMER, sendData);
//minTimer.start();
}
public function getResp():String
{
return "Resr";
}
public function resultHandler(event:ResultEvent):void
{
//person = new currentPerson(event.result.current.username, event.result.current.img, event.result.current.rank);
playersData = event.result.players.player;
Alert.show("resh");
}
public function sendData():void
{
usersListService.send();
}
public function getPlayersList():ArrayCollection
{
Alert.show(playersData.toString());
return playersData;
}
}
}
The problem is that nothing is shown in the datagrid
I am just a beginner, so please advice what did I wrong with the class
The result function (in ListOfPlayers class) should give the list of players and not the function that is calling the webservice.
What you could do is add this in server class:
[Bindable]
public var playersData:ArrayCollection;
and in your view add also this variable with the bindable tag and set the value add this line in main():
playersData = users.playersData;
then the datagrid dataprovider is "{playersData}"
this should work. But with XML list it is always a bit difficult to know how deep you are in the tree ;)