flex参数,解决Flex从URL里获取参数的问题 和页...

最近开始使用Flex进行开发。需要从URL获取参数,查了好些网页也没有找到适用的方法。但最中还是找到了解决方法,现写出来,与大家分享,节省查阅的时间。
对于FLex使用参数就两个地方(我是个菜鸟,目前就知道两个) ,一个是mx:Script里,另一个就是组件(如Label或TextInput等)。有如下格式URL:a.swf?name=1&pass=2;(注意那个红色的“?”)在组件中使用只要定义好一个变量,然后直接使用{name}就可以了,而对于mx:Script里则不行。如下:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApplication()" >
<mx:Script>
private function initApplication():void
{
trace (this.parameters.name+":"+this.parameters.pass);
}
</mx:Script>
<mx:Label id="path" width="100%" text="{name}" />
</mx:Application>
FLEX的页面传值
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
private function _disibledevent=>
}
</mx:Script>
<mx:Button x="186" y="202" label="Button" click="onclik();"/>
<mx:TextInput x="141" y="143" id="Textl"/>
</mx:Application>
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="init();" >
<mx:Script>
import mx.controls.Alert;
private function init():void
{
//Alert.show(this.parameters.a);
TextInput1.text=this.parameters.a;
}
</mx:Script>
<mx:TextInput x="151" y="77" id="TextInput1"/>
</mx:Application>
Tags:  flex参数

延伸阅读

最新评论

发表评论