I need to change a httpservice url at runtime. However when I change
the url the xml is not being updated, it is always one step behind.

See the following example app, the xml displayed in the Alert box is
always from the previous call.

How do I get it to update correctly?

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" creationPolicy="all"
creationComplete="onCreationComplete();" width="687" height="332">
<mx:HTTPService id="gsservice" url="test0.xml" resultFormat="e4x"
result="gsData = gsservice.lastResult as XML"/>
<mx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
import mx.controls.Alert;
private var gsData:XML;

private function onCreationComplete():void{
gsservice.send();
}

private function test(file:String):void {
gsservice.url = file;
gsservice.send();
gsData = gsservice.lastResult as XML;
Alert.show(gsData.toString());
}
]]>
</mx:Script>
<mx:Button x="10" y="10" label="Test 1" width="180"
click="test('test1.xml');"/>
<mx:Button x="10" y="40" label="Test 2" width="180"
click="test('test2.xml');"/>
</mx:Application> 

Reply via email to