Mr_Splash
asked on
Displaying an XML value in a Label
I've been struggling with this for a long time now.
I have an xml file that only contains the markup below.
I'm looking for the simplest way to take the 10 value and present it in a Label in Flex.
Thanks for your help
I have an xml file that only contains the markup below.
I'm looking for the simplest way to take the 10 value and present it in a Label in Flex.
Thanks for your help
<donations>
<amount>
10
</amount>
</donations>
This is one way ~
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<!-- Declare the data model in MXML
Optionally, to declare an external source
<mx:Model id="data" source="fileName" />
-->
<mx:Model id="data">
<root>
<donations>
<amount>
10
</amount>
</donations>
</root>
</mx:Model>
<mx:Label id="DonationAmount" text="{data.donations.amount}" />
</mx:Application>
ASKER
Thanks guys,
But I can't get either to work.
@anakinjay
I get this error with your code
Can not resolve a multiname reference unambiguously. mx.rpc.http.mxml:HTTPServi ce (from C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\frameworks\li bs\rpc.swc (mx/rpc/ht tp/mxml/HT TPService) ) and mx.rpc.http:HTTPService (from C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\frameworks\li bs\rpc.swc (mx/rpc/ht tp/HTTPSer vice)) are available.
@bglodde
I get this error with your code
Problem parsing external XML: http://localhost//Build/upload/ssf.xml - http://localhost/Build/upload/ssf.xml
But I can't get either to work.
@anakinjay
I get this error with your code
Can not resolve a multiname reference unambiguously. mx.rpc.http.mxml:HTTPServi
@bglodde
I get this error with your code
Problem parsing external XML: http://localhost//Build/upload/ssf.xml - http://localhost/Build/upload/ssf.xml
are you running it in Flex Builder? or just the SDK?
if it's just the SDK you might have to add the httpservice to your program.... but I'm really not sure, I only ever use flex builder.
try adding this to the top of your flex mxml...
if it's just the SDK you might have to add the httpservice to your program.... but I'm really not sure, I only ever use flex builder.
try adding this to the top of your flex mxml...
<mx:Script >
<![CDATA[
import mx.rpc.http.HTTPService;
]]>
</mx:Script>
oh, and you probably need this if you don't have it:
xmlns:mx="http://www.adobe.com/2006/mxml"
added to your mx:Application tag as an option
so like:
xmlns:mx="http://www.adobe.com/2006/mxml"
added to your mx:Application tag as an option
so like:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" (other options go here) >
For my method, your xml needs to have a <root> element. Assure your xml has some sort of root element other than <donations>.
ASKER
@anakinjay
the xmlns:mx parameter is in there. I'm using Flex Builder 3, I'm getting the same error even with your import script.
@bglodde
Literally added <root></root> on the outsides of my xml but it didn't make a difference.
the xmlns:mx parameter is in there. I'm using Flex Builder 3, I'm getting the same error even with your import script.
@bglodde
Literally added <root></root> on the outsides of my xml but it didn't make a difference.
Your external xml should look like this
<?xml version="1.0"?>
<root>
<donations>
<amount>10</amount>
</donations>
</root>
"Can not resolve a multiname reference unambiguously"
that means that you have two or more items named "HTTPService"
did you give anything an ID of HTTPService?
Are you loading any other APIs with an HTTPService in them? (any number of flash APIs would do the trick.)
Try doing this. This tells it exactly what API you're trying to use.
that means that you have two or more items named "HTTPService"
did you give anything an ID of HTTPService?
Are you loading any other APIs with an HTTPService in them? (any number of flash APIs would do the trick.)
Try doing this. This tells it exactly what API you're trying to use.
<mx:Script >
<![CDATA[
import mx.rpc.http.HTTPService;
var xmlList:HTTPService = new mx.rpc.http.HTTPService;
xmlList.url="http://yourxmlfile";
xmlList.send();
]]>
</mx:Script>
<mx:Label id="labelName" text="{xmlList.lastResult.donations.amount}" />
Oh, and if that doesn't work, try changing the var line to this:
var xmlList:mx.rpc.http.HTTPSe rvice = new mx.rpc.http.HTTPService;
var xmlList:mx.rpc.http.HTTPSe
ASKER
@bglodde
My XML is the same as yours, same error.
@anakinjay
I get a new error with that script (the same with both versions of the var.) on the last two lines inside the CDATA.
"Access of undefined property xmlList"
My XML is the same as yours, same error.
@anakinjay
I get a new error with that script (the same with both versions of the var.) on the last two lines inside the CDATA.
"Access of undefined property xmlList"
I just noticed you are using an external xml file, but it is not located where the Flex application is.
Either call the file with the previous source with a local path:
<mx:Model id="data" source="test/data.xml" />
Or use the following snippet to retrieve the XML file from a remote location (eg http://localhost/Build/upload/ssf.xml).
Either call the file with the previous source with a local path:
<mx:Model id="data" source="test/data.xml" />
Or use the following snippet to retrieve the XML file from a remote location (eg http://localhost/Build/upload/ssf.xml).
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="creationCompleteHandler()">
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
private function creationCompleteHandler():void
{
AppDataService.send();
}
private function errorHandler(err:FaultEvent):void
{
Alert.show(err.message.toString(), "Error");
}
private function resultHandler(evt:ResultEvent):void
{
DonationAmount.text = evt.result.donations.amount;
}
]]>
</mx:Script>
<mx:HTTPService id="AppDataService" fault="errorHandler(event)" showBusyCursor="true"
url="http://localhost/Build/upload/ssf.xml" result="resultHandler(event)" resultFormat="e4x" />
<mx:Label id="DonationAmount" />
</mx:Application>
ASKER
Thanks bglodde. But I'm afraid that also gives me the "Can not resolve a multiname reference unambiguously"
Odd. I don't get that error in Flex builder when I fire up the above example.
Can you show the code that produces this error (in its entirety if possible) - there has to be something else wrong since there is nothing ambiguous about the above example.
Can you show the code that produces this error (in its entirety if possible) - there has to be something else wrong since there is nothing ambiguous about the above example.
ASKER
No problem.
musicScript.as is the standards MySQL functions code that Flex generates.
imageUpload and audioUpload handle file uploads.
musicScript.as is the standards MySQL functions code that Flex generates.
imageUpload and audioUpload handle file uploads.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="creationCompleteHandler; initApp(); initAudio(); initImage();" paddingTop="20" paddingRight="20" paddingLeft="20" paddingBottom="20" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#000000, #686868]">
<mx:Script source="musicScript.as" />
<mx:Script source="imageUpload.as" />
<mx:Script source="audioUpload.as" />
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; import mx.controls.Alert;
private function creationCompleteHandler():void {AppDataService.send();}
private function errorHandler(err:FaultEvent):void {Alert.show(err.message.toString(), "Error");}
private function donResultHandler(evt:ResultEvent):void {DonationAmount.text = evt.result.donations.amount;}
]]>
</mx:Script>
<mx:HTTPService id="AppDataService" fault="errorHandler(event)" showBusyCursor="true" url="http://localhost/Build/upload/ssf.xml" result="donResultHandler(event)" resultFormat="e4x" />
<mx:ViewStack id="applicationScreens" width="800" height="500">
<mx:Panel id="view" width="800" layout="vertical" title="Song Administration" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10" color="#FFFFFF" height="500">
<mx:HBox width="100%" color="#0B333C">
<mx:Label text="Donations:"/>
<mx:Label id="DonationAmount" text=""/>
</mx:HBox>
<mx:DataGrid id="dataGrid"
dataProvider="{dataArr}"
rowCount="8"
editable="true"
resizableColumns="true"
headerRelease="setOrder(event);"
width="100%" color="#0B333C" height="100%">
<mx:columns>
<mx:DataGridColumn headerText="Song Name" dataField="songNameCol" />
<mx:DataGridColumn headerText="Album" dataField="albumNameCol" />
<mx:DataGridColumn headerText="Sort Order" width="100" dataField="sortOrderCol" />
</mx:columns>
</mx:DataGrid>
<mx:HBox width="100%">
<mx:Button id="btnAddNew" click="goToUpdate()" icon="@Embed('icons/AddRecord.png')" toolTip="Add Record" x="10" bottom="10"/>
<mx:Button id="btnDelete" click="deleteItem()" icon="@Embed('icons/DeleteRecord.png')" toolTip="Delete Record" x="58" bottom="10"/>
<mx:Spacer width="100%"/>
<mx:Label text="Search by Song Name" right="300" bottom="11" color="#0B333C"/>
<mx:TextInput id="filterTxt" width="238" toolTip="Search by songName" enter="filterResults()" right="58" bottom="11" color="#0B333C"/>
<mx:Button click="filterResults()" id="filterButton" icon="@Embed('icons/SearchRecord.png')" toolTip="Search by songName" right="10" bottom="10"/>
</mx:HBox>
</mx:Panel>
<mx:Panel id="update" width="800" layout="vertical" title="Add New Song" paddingBottom="10" paddingLeft="10" paddingRight="10" paddingTop="10" color="#FFFFFF" height="500">
<mx:Form width="100%" id="songsForm">
<mx:FormItem label="Song Name:" id="songName_form" color="#0B333C">
<mx:TextInput id="songNameCol" text=""/>
</mx:FormItem>
<mx:FormItem label="Album Name:" id="albumName_form" color="#0B333C">
<mx:TextInput id="albumNameCol" text=""/>
</mx:FormItem>
<mx:FormItem label="Sort Order:" id="sortOrder_form" color="#0B333C">
<mx:TextInput id="sortOrderCol" text="0"/>
</mx:FormItem>
<mx:FormItem label="Mp3:" id="mp3Path_form" color="#0B333C">
<mx:HBox><mx:Button click="uploadAudio();" label="Browse"/><mx:Label text="" id="audioText"/></mx:HBox>
<mx:Text id="mp3PathCol" text="" height="0" width="0"/>
</mx:FormItem>
<mx:FormItem label="Artwork:" id="thumbPath_form" color="#0B333C">
<mx:HBox><mx:Button click="uploadImage();" label="Browse"/><mx:Label text="" id="imageText"/></mx:HBox>
<mx:Text id="thumbPathCol" text="" height="0" width="0"/>
</mx:FormItem>
</mx:Form>
<mx:HBox>
<mx:Button label="Save" id="btnSubmit" click="insertItem()" right="81" bottom="10" color="#0B333C" enabled="false"/>
<mx:Button label="Cancel" id="btnCancel" click="goToView()" right="10" bottom="10" color="#0B333C"/>
</mx:HBox>
</mx:Panel>
</mx:ViewStack>
</mx:Application>
It appears the error is coming from one of the three external .as files, likely due to using a different HTTPService object. You might consider adding additional mx:HTTPService tags in the MXML rather than programmatically creating HTTPService objects in the .as file - this would probably clear up the import collision.
ASKER
Ok, You'll have to forgive my noviceness as I'm not sure where the problem is, below is audioUpload.as. imageUpload.as is identical except it different variable names.
musicScript.as is the one generated by Flex when choosing "Create application from database..." But I can post this if you like.
Thanks again for your help.
musicScript.as is the one generated by Flex when choosing "Create application from database..." But I can post this if you like.
Thanks again for your help.
// ActionScript file
private var audioUrlRequest:URLRequest;
private var audioReferenceList:FileReferenceList;
private var audioScript:String = "http://localhost/Build/upload/uploadAudio.php";
private var audUp:int = 0;
private function initAudio():void {
audioUrlRequest = new URLRequest(audioScript);
audioReferenceList = new FileReferenceList();
audioReferenceList.addEventListener(Event.SELECT, audioSelectedHandler);
}
private function uploadAudio():void {
audioReferenceList.browse();
}
private function audioSelectedHandler(event:Event):void {
var audioReference:FileReference;
var audioReferenceList:FileReferenceList = FileReferenceList(event.target);
var audioList:Array = audioReferenceList.fileList;
// get the first file that the user chose
audioReference = FileReference(audioList[0]);
// upload the file to the server side script
audioReference.addEventListener(Event.COMPLETE, audioCompleteHandler);
audioReference.upload(audioUrlRequest);
// update the status text
audioText.text = "Uploading...";
}
private function audioCompleteHandler(event:Event):void {
audioText.text = "File Uploaded: " + event.target.name;
var fileName:String = event.target.name;
var firstPart:Array = fileName.split(".");
mp3PathCol.text=firstPart[0];
audUp = 1;
if (imgUp == 1) {
btnSubmit.enabled=true;
}
}
Yes please post the other two files and let's see if we can pinpoint & solve the issue.
ASKER
imageUpload.as
// ActionScript file
private var imageUrlRequest:URLRequest;
private var imageReferenceList:FileReferenceList;
private var imageScript:String = "http://localhost/Build/upload/uploadImage.php";
private var imgUp:int = 0;
private function initImage():void {
imageUrlRequest = new URLRequest(imageScript);
imageReferenceList = new FileReferenceList();
imageReferenceList.addEventListener(Event.SELECT, imageSelectedHandler);
}
private function uploadImage():void {
imageReferenceList.browse();
}
private function imageSelectedHandler(event:Event):void {
var imageReference:FileReference;
var imageReferenceList:FileReferenceList = FileReferenceList(event.target);
var imageList:Array = imageReferenceList.fileList;
// get the first file that the user chose
imageReference = FileReference(imageList[0]);
// upload the file to the server side script
imageReference.addEventListener(Event.COMPLETE, imageCompleteHandler);
imageReference.upload(imageUrlRequest);
// update the status text
imageText.text = "Uploading...";
}
private function imageCompleteHandler(event:Event):void {
imageText.text = "File Uploaded: " + event.target.name;
imgUp = 1;
thumbPathCol.text = event.target.name;
if (audUp == 1) {
btnSubmit.enabled=true;
}
}
ASKER
musicscript.as
/**
* ActionScript source file that defines the UI logic and some of the data access code.
* This file is linked into the main application MXML file using the mx:Script tag.
* Most of the functions in this file are called by event handlers defined in
* the MXML.
*/
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.controls.dataGridClasses.DataGridItemRenderer;
import mx.events.CloseEvent;
import mx.events.DataGridEvent;
import mx.rpc.events.ResultEvent;
import mx.managers.CursorManager;
import mx.utils.ObjectUtil;
import mx.rpc.http.HTTPService;
import mx.rpc.events.FaultEvent;
import mx.rpc.AsyncToken;
//include the constant definition of the server endpoint URL
include "musicconfig.as";
/**
* gateway : this is the communication layer with the server side php code
*/
private var gateway:HTTPService = new HTTPService();
/**
* the array collection holds the rows that we use in the grid
*/
[Bindable]
public var dataArr:ArrayCollection = new ArrayCollection();
/**
* column that we order by. This is updated each time the users clicks on the
* grid column header.
* see headerRelease="setOrder(event);" in the DataGrid instantiation in the
* mxml file
*/
private var orderColumn:Number;
/**
* the list of fields in the database table
* needed to parse the response into hashes
*/
private var fields:Object = { 'id':Number, 'songName':String, 'albumName':String, 'mp3Path':String, 'thumbPath':String, 'sortOrder':Number};
/**
* Executes when the mxml is completed loaded. Initialize the Rest Gateway.
*/
private function initApp():void
{
/**
* initialize the gateway
* - this will take care off server communication and simple xml protocol.
*/
gateway.url = ENDPOINT_URL;
gateway.method = "POST";
gateway.useProxy = false;
gateway.resultFormat = "e4x";
/**
* set the event handler which prevents editing of the primary key
*/
dataGrid.addEventListener(DataGridEvent.ITEM_EDIT_BEGINNING, editCellHandler);
/**
* set the event handler which triggers the update actions - everytime an
* edit operation is finished
*/
dataGrid.addEventListener(DataGridEvent.ITEM_EDIT_END, editCellEnd);
gateway.addEventListener(ResultEvent.RESULT, resultHandler);
gateway.addEventListener(FaultEvent.FAULT, faultHandler);
fill();
}
/**
* Disallow editing of the primary key column.
* @param e DataGridEvent contains details about the row and column of the grid
* where the user clicked
*/
private function editCellHandler(e:DataGridEvent):void
{
/**
* if the user clicked on the primary key column, stop editing
*/
if(e.dataField == "idCol")
{
e.preventDefault();
return;
}
}
/**
* Click handler for "Filter" button.
* When setting another filter, refresh the collection, and load the new data
*/
private function filterResults():void
{
fill();
}
/**
* Event handler triggered when the user finishes editing an entry
* triggers an "update" server command
*/
private function editCellEnd(e:DataGridEvent):void
{
var dsRowIndex:int = e.rowIndex;
var dsFieldName:String = e.dataField;
var dsColumnIndex:Number = e.columnIndex;
var vo:* = dataArr[dsRowIndex];
var col:DataGridColumn = dataGrid.columns[dsColumnIndex];
var newvalue:String = dataGrid.itemEditorInstance[col.editorDataField];
trace("a:" + dsRowIndex + ", " + dsFieldName + ", " + dsColumnIndex);
var parameters:* =
{
"id": vo.idCol, "songName": vo.songNameCol, "albumName": vo.albumNameCol, "mp3Path": vo.mp3PathCol, "thumbPath": vo.thumbPathCol, "sortOrder": vo.sortOrderCol }
parameters[dsFieldName.substr(0,dsFieldName.length-3)] = newvalue;
/**
* execute the server "update" command
*/
doRequest("Update", parameters, saveItemHandler);
}
/**
* result handler for the "update" server command.
* Just alert the error, or do nothing if it's ok - the data has already
* been updated in the grid
*/
private function saveItemHandler(e:Object):void
{
if (e.isError)
{
Alert.show("Error: " + e.data.error);
}
else
{
}
}
/**
* dragHeader handler for the datagrid. This handler is executed when the user
* clicks on a header column in the datagrid
* updates the global orderColumn variable, refreshes the TableCollection
* @param event DataGridEvent details about the column
*/
private function setOrder(event:DataGridEvent):void
{
orderColumn = event.columnIndex;
var col:DataGridColumn = dataGrid.columns[orderColumn];
col.sortDescending = !col.sortDescending;
event.preventDefault();
fill();
}
/**
* Click handler for the "Save" button in the "Add" state
* collects the information in the form and adds a new object to the collection
*/
private function insertItem():void {
var parameters:* =
{
"method": "Insert", "songName": songNameCol.text, "albumName": albumNameCol.text, "mp3Path": mp3PathCol.text, "thumbPath": thumbPathCol.text, "sortOrder": sortOrderCol.text };
/**
* execute the server "insert" command
*/
doRequest("Insert", parameters, insertItemHandler);
}
/**
* Result handler for the insert call.
* Alert the error if it exists
* if the call went through ok, return to the list, and refresh the data
*/
private function insertItemHandler(e:Object):void
{
if (e.isError)
{
Alert.show("Error: " + e.data.error);
}
else
{
goToView();
fill();
}
}
/**
* general utility function for refreshing the data
* gets the filtering and ordering, then dispatches a new server call
*
*/
private function fill():void
{
/**
* find the order parameters
*/
var desc:Boolean = false;
var orderField:String = '';
if(!isNaN(orderColumn))
{
var col:DataGridColumn = dataGrid.columns[orderColumn];
desc = col.sortDescending;
//remove the 'Col' particle
orderField = col.dataField.substr(0,col.dataField.length-3);
}
dataGrid.enabled = false;
CursorManager.setBusyCursor();
var parameters:* =
{
"orderField": orderField,
"orderDirection": (desc) ? "DESC" : "ASC",
"filter": filterTxt.text
}
/**
* execute the server "select" command
*/
doRequest("FindAll", parameters, fillHandler);
}
/**
* result handler for the fill call.
* if it is an error, show it to the user, else refill the arraycollection with the new data
*
*/
private function fillHandler(e:Object):void
{
if (e.isError)
{
Alert.show("Error: " + e.data.error);
}
else
{
dataArr.removeAll();
for each(var row:XML in e.data.row)
{
var temp:* = {};
for (var key:String in fields)
{
temp[key + 'Col'] = row[key];
}
dataArr.addItem(temp);
}
CursorManager.removeBusyCursor();
dataGrid.enabled = true;
}
}
/**
* Click handler for the "delete" button in the list
* confirms the action and launches the deleteClickHandler function
*/
private function deleteItem():void {
if (dataGrid.selectedItem)
{
Alert.show("Are you sure you want to delete the selected record?",
"Confirm Delete", 3, this, deleteClickHandler);
}
}
/**
* Event handler function for the Confirm dialog raises when the
* Delete button is pressed.
* If the pressed button was Yes, then the product is deleted.
* @param object event
* @return nothing
*/
private function deleteClickHandler(event:CloseEvent):void
{
if (event.detail == Alert.YES)
{
var vo:* = dataGrid.selectedItem;
var parameters:* =
{
"id": vo.idCol
}
/**
* execute the server "delete" command
*/
doRequest("Delete", parameters, deleteHandler);
setTimeout( function():void
{
dataGrid.destroyItemEditor();
},
1);
}
}
public function deleteHandler(e:*):void
{
if (e.isError)
{
Alert.show("Error: " + e.data.error);
}
else
{
var id:Number = parseInt(e.data.toString(), 10);
for (var index:Number = 0; index < dataArr.length; index++)
{
if (dataArr[index].idCol == id)
{
dataArr.removeItemAt(index);
break;
}
}
}
}
/**
* deserializes the xml response
* handles error cases
*
* @param e ResultEvent the server response and details about the connection
*/
public function deserialize(obj:*, e:*):*
{
var toret:Object = {};
toret.originalEvent = e;
if (obj.data.elements("error").length() > 0)
{
toret.isError = true;
toret.data = obj.data;
}
else
{
toret.isError = false;
toret.metadata = obj.metadata;
toret.data = obj.data;
}
return toret;
}
/**
* result handler for the gateway
* deserializes the result, and then calls the REAL event handler
* (set when making a request in the doRequest function)
*
* @param e ResultEvent the server response and details about the connection
*/
public function resultHandler(e:ResultEvent):void
{
var topass:* = deserialize(e.result, e);
e.token.handler.call(null, topass);
}
/**
* fault handler for this connection
*
* @param e FaultEvent the error object
*/
public function faultHandler(e:FaultEvent):void
{
var errorMessage:String = "Connection error: " + e.fault.faultString;
if (e.fault.faultDetail)
{
errorMessage += "\n\nAdditional detail: " + e.fault.faultDetail;
}
Alert.show(errorMessage);
}
/**
* makes a request to the server using the gateway instance
*
* @param method_name String the method name used in the server dispathcer
* @param parameters Object name value pairs for sending in post
* @param callback Function function to be called when the call completes
*/
public function doRequest(method_name:String, parameters:Object, callback:Function):void
{
// add the method to the parameters list
parameters['method'] = method_name;
gateway.request = parameters;
var call:AsyncToken = gateway.send();
call.request_params = gateway.request;
call.handler = callback;
}
/**
* Click handler when the user click the "Create" button
* Load the "Update" canvas.
*/
public function goToUpdate():void
{
applicationScreens.selectedChild = update;
}
/**
* Load the "View" canvas.
*/
public function goToView():void
{
applicationScreens.selectedChild = view;
}
Flex is getting confused on which HTTPService to use - let's change the way you are using the service to pure actionscript and remove the HTTPService tag.
This should resolve the problem.
This should resolve the problem.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="creationCompleteHandler()">
<mx:Script source="test/musicscript.as" />
<mx:Script source="test/imageUpload.as" />
<mx:Script source="test/audioUpload.as" />
<mx:Script>
<![CDATA[
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.controls.Alert;
private function creationCompleteHandler():void
{
var service:HTTPService = new HTTPService();
service.url = "http://localhost/Build/upload/ssf.xml";
service.resultFormat = "e4x";
service.addEventListener(ResultEvent.RESULT, resultHandler);
service.addEventListener(FaultEvent.FAULT, errorHandler);
service.send();
}
private function errorHandler(err:FaultEvent):void
{
Alert.show(err.message.toString(), "Error");
}
private function resultHandler(evt:ResultEvent):void
{
DonationAmount.text = evt.result.donations.amount;
}
]]>
</mx:Script>
<mx:Label id="DonationAmount" />
</mx:Application>
ASKER
Hi bglodde,
Sorry but there are now new errors.
test.mxml is the code you gave in your last post.
Sorry but there are now new errors.
test.mxml is the code you gave in your last post.
Ambiguous reference to resultHandler. admin/src musicScript.as line 76
Ambiguous reference to resultHandler. admin/src test.mxml line 20
Duplicate function definition. admin/src test.mxml line 30
Incompatible override. admin/src test.mxml line 30
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you, this works perfectly.
Awesome, thank you - glad I could help!
There is no proper solution for my search word,
if it's an HTTPService, it would be something like this:
Open in new window