首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

Flex 四 接收外部参数(1)

2012-10-07 
Flex 4 接收外部参数(1)(一)使用flashVars传递1 更改index.template.html第43行为:?trace(URL参数)tr

Flex 4 接收外部参数(1)

(一)使用flashVars传递

1 更改index.template.html第43行为:

?

trace("URL参数=>");trace(app.url);

?

?输出结果如下:

?

HTML参数=>{"age":20,"sex":1}?

?

(四)代码汇总如下:

?

?写道import com.adobe.serialization.json.JSON;
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
import mx.managers.BrowserManager;
import mx.managers.IBrowserManager;
import mx.utils.URLUtil;

protected function creationCompleteHandler(event:FlexEvent):void
{
var app:Application = FlexGlobals.topLevelApplication as Application;
trace("外部参数=>");
trace(JSON.encode(app.parameters));
trace("URL参数=>");
trace(app.url);
var bm:IBrowserManager = BrowserManager.getInstance();
bm.init();//注意,必须初始化一下,否则为空
var param:Object = URLUtil.stringToObject(bm.fragment, "&");
trace("HTML参数=>");
trace(JSON.encode(param));
}

?? ?详细请下载附件,其中项目使用了as3corelib.swc包,请自己搜索或者联系我。

?

注1:

swfobject.embedSWF(swfUrl, id, width, height, version, expressInstallSwfurl, flashvars, params, attributes)有5个必须的参数和4个可选的参数:

?? ?1. swfUrl(String,必须的)指定SWF的URL。

?? ?2. id(String,必须的)指定将会被Flash内容替换的HTML元素(包含你的替换内容)的id。

?? ?3. width(String,必须的)指定SWF的宽。

?? ?4. height(String,必须的)指定SWF的高。

?? ?5. version(String,必须的)指定你发布的SWF对应的Flash Player版本(格式为:major.minor.release)。

?? ?6. expressInstallSwfurl(String,可选的)指定express install SWF的URL并激活Adobe express install [ http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=6a253b75 ]。

?? ?7. flashvars(String,可选的)用name:value对指定你的flashvars。

?? ?8. params(String,可选的)用name:value对指定你的嵌套object元素的params。

?? ?9. attributes(String,可选的)用name:value对指定object的属性。

?

注2:对于flex3,,flashVars参考链接:

http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html

http://livedocs.adobe.com/flex/3/html/help.html?content=deep_linking_5.html#245869:

?

?

?

?

?

热点排行