[Flex] Accessing variables

Associate
Joined
30 Dec 2005
Posts
415
Greetings all!

I've started to delve into the world of Flex today, and I was making good progress until I hit a bit of a problem..

I've got an HTTPService loading an xml file..
Code:
<mx:HTTPService 
        id="xmlService"
        url="xml.server_stats.php" 
        resultFormat="e4x"
        result="xmlResultHandler(event);"
        fault="xmlFaultHandler(event);"
    />

.. and the script which handles the service...
Code:
private function xmlResultHandler(event:ResultEvent):void
{
      server = event.result as XML;  
}

All is good so far. It allows me to do things like:
Code:
<mx:Panel title="{server.name}" width="100%" height="100%">

However, when I try to read that variable into the script, I get an "Access of undefined property server" error.
Code:
<mx:Script>
  <![CDATA[
    Alert.show(server.name);
  ]]>
</mx:Script>

Does anybody have any ideas how I correctly reference to the variable? I don't seem to be able to access it from within script tags, but I can from mxml.

Cheers!
 
Back
Top Bottom