浏览 4255 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2010-02-10
最后修改:2010-02-10
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="initializeHandler(event)"> <mx:Script> <![CDATA[ import flash.net.*; // flash.net.URLLoader private var _countriesService:URLLoader; private var _statesService:URLLoader; private function initializeHandler(event:Event):void { _countriesService = new URLLoader(); _countriesService.addEventListener(Event.COMPLETE, countriesCompleteHandler); var request:URLRequest = new URLRequest("http://www.rightactionscript.com/states/xml/countries.xml"); _countriesService.load(request); _statesService=new URLLoader(); _statesService.addEventListener(Event.COMPLETE, statesCompleteHandler); XML.ignoreWhitespace=true; } private function countriesCompleteHandler(event:Event):void { var xml:XML=new XML(_countriesService.data); country.dataProvider=xml.children(); } private function statesCompleteHandler(event:Event):void { var xml:XML=new XML(_statesService.data); state.dataProvider=xml.children(); } private function changeHandler(event:Event):void { var request:URLRequest=new URLRequest("http://www.rightactionscript.com/states/xml/states.php"); var parameters:URLVariables=new URLVariables(); parameters.country=country.value; request.data=parameters; _statesService.load(request); } ]]> </mx:Script> <mx:VBox> <mx:ComboBox id="country" change="changeHandler(event)"/> <mx:ComboBox id="state"/> </mx:VBox> </mx:Application> 分析: changeHandler方法里的请求URL,可以进行设计,可以在URL中添加变量、参数。使用ComboBox来控制发送参数或者请求的URL地址,同样也可以,使用TextInput或者TextField来决定请求或交互的参数。 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2010-07-27
代码能加上点注释吗?看着效果更好。
|
|
返回顶楼 | |