Actionscript3: How to Send Querystring Arguments and Parse XML Feed
I need to call a REST web service that provides an XML feed of weather conditions. I have 13 cities for which conditions are needed, and only 3 nodes for each city are required (vs. the entire feed).
My very basic first attempt is as follows:
public class Main extends MovieClip {
public function Main() {
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest
("http://MyUrl?querystringx"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
Parse(xmlData);
}
}
}
First, how do I parse the 3 nodes , and ? Next, is there a way to pass a different querystring argument for each of the 13 cities? Finally, how would I add these values to an FLV that's been imported开发者_如何学Python and placed on stage? The FLV displays a geographical area and pans from east to west plotting cities as it goes. At each city plot, the 3 node values need to be "superimposed" onto the FLV.
Thanks much for your help and guidance.
You can use URLRequest and URLVariables and to pass variable like that
var url:String = "http://MyUrl"; var request:URLRequest = new URLRequest(url); var variables:URLVariables = new URLVariables(); variables.exampleSessionId = new Date().getTime(); variables.exampleUserLabel = "guest"; xmlLoader.load(request);
see Working with external data and URLVariables
Hopes that helps
精彩评论