通过页面传递参数到flex中的几种方法
1.在<Object>和<embed>中设置flashVars参数,例如:
<object id=’mySwf’ classid=’clsid:D27CDB6E-AE6D-11cf-96B8-444553540000′ codebase=’http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab’ height=’100%’ width=’100%’>
<param name=’src’ value=’FlashVarTest.swf’/>
<param name=’flashVars’ value=’firstName=Nick&lastName=Danger’/>
<embed name=’mySwf’ src="’FlashVarTest.swf’" mce_src="’FlashVarTest.swf’" pluginspage=’http://www.adobe.com/go/getflashplayer’ height=’100%’ width=’100%’ flashVars=’firstName=Nick&lastName=Danger’/>
<embed src="’TitleTest.mxml.swf?myName=Danger’" mce_src="’TitleTest.mxml.swf?myName=Danger’" … />
</object>
2.或者在<Object>和<embed>中的src属性中直接加参数,例如:
<object … >
<param name=’src’ value=’TitleTest.mxml.swf?myName=Danger’>
…
<embed src="’TitleTest.mxml.swf?myName=Danger’" mce_src="’TitleTest.mxml.swf?myName=Danger’" … />
</object>
3.如果通过url直接访问Flash,可以直接再后面加参数,例如:
http://localhost:8100/flex/myApp.swf?myName=Nick&myHometown=San
如何在Flex中读取这些参数:
可以用Application.application.parameters或LoaderConfig.parameters获得外部参数。
但是切忌:只能在Application部署完成之后才能获取这些参数。也就是在派发creationComplete之后才能获得。例如:
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” width=”100%” height=”100%”
layout=”absolute” creationComplete=”initApp()” initialize=”init()”>
<mx:Script>
<!--[CDATA[
import mx.core.Application
private function i
相关文档:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal">
<mx:Panel width="392" height="300" layout="absolute">
<mx:Label x="19" y="10" text="{user}" width="171" height="20"/>
<mx ......
Flex Builder 3.0正式版:
http://download.macromedia.com/pub/flex/flex_builder/FB3_win.exe
或
http://www.adobe.com/cfusion/tdrc/index.cfm?product=flex
或
http://trials.adobe.com/Applications/Flex/FlexBuilder/3/FB3_WWEJ_Plugin.exe
AIR1.0 正式版:
http://airdownload.adobe.com/air ... ob ......
自定义类(BroadCastMarquee.as):
package marquee
{
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.geom.Rectangle;
import flash.text.TextField;
import flash.text.TextFiel ......
var login:infoChange=infoChange(PopUpManager.createPopUp( this, infoChange , true));
login.x=250;
login.y=150;
login.userid.text=dg.selectedItem.aa;
login.username.text=dg.selectedItem.bb;
......