Problem retrieving XML data via Flex/ActionScript

Can anyone tell me why the following ActionScript code doesn't work please? I simply want to display the XML "id" in the Alert box, but it doesn't work and I've no idea why.

Any help appreciated. Thanks in advance.
// ACTIONSCRIPT
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx"
                       creationComplete="windowedapplication1_creationCompleteHandler(event)">
    <fx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import mx.events.FlexEvent;
            import mx.rpc.events.ResultEvent;
            
            // fetch ID and display in Alert window
            protected function xmlService_resultHandler(event:ResultEvent):void
            {
                var id:String    =    event.result.data.id;
                Alert.show(id, 'ID');
            }

            // retrieve XML data
            protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
            {
                xmlService.send();
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <s:HTTPService id="xmlService"
                       url="URL"
                       method="GET"
                       useProxy="false"
                       resultFormat="e4x"
                       result="xmlService_resultHandler(event)"/>
    </fx:Declarations>
</s:WindowedApplication>

// XML
<?xml version="1.0"?>
<data>
  <id>products</id>
</data>

Open in new window

DReade83Asked:
Who is Participating?
 
DReade83Connect With a Mentor Author Commented:
It's OK, I've sorted it.
var data:XML   =  event.result as XML;
var id:String  =  data.id;

Alert.show(id, 'ID');

Open in new window

0
 
scooby_56Commented:
try to trace some values.

trace(event)
trace(event.result.data)
trace(event.result.data.data.id)
0
All Courses

From novice to tech pro — start learning today.