Flash的URLVariables类
- 05月 15th, 2008
-
URLVariables未必仅仅用于URL
例如我们需要定义很多字符串,但是这些字符串又有很多共性,就可以用URLVariables来存储。public function init():void{ var s:String = "a=1&b=2"; var variables:URLVariables = new URLVariables(s); trace(variables.a); }当然,我们也可以用它来分析外部数据:
czbin.mxml
<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();"> <mx:Script> <![CDATA[ import mx.controls.Alert; public function init():void{ var url:String = 'czbin.com.txt'; var req:URLRequest = new URLRequest(url); var loader:URLLoader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.VARIABLES; loader.addEventListener(Event.COMPLETE,com) loader.load(req); } public function com(e:Event):void{ Alert.show(e.target.data.a); } ]]> </mx:Script> </mx:Application>czbin.com.txt
a=1&b=2