日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > HTML >内容正文

HTML

HTML向Flex传参

發布時間:2024/4/14 HTML 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 HTML向Flex传参 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近有個需求,要在網站中播放一段介紹性的視頻,于是做了一個用Flex播放視頻的demo。播放視頻的代碼是以前在網上找的,但是從html頁面獲得視頻地址的時候參數傳遞問題浪費了很多時間,現整理總結如下:

在Flex中接收參數很簡單,通過FlexGlobals.topLevelApplication.parameters或直接用parameters,文檔中對parameters的介紹如下:

spark.components.Application.parameters():Object
[只讀] 包含表示提供給此 Application 的參數的名稱-值對的 Object。

可以使用 for-in 循環來提取 parameters Object 中的所有名稱和值。

參數有兩個源:Application 的 URL 中的查詢字符串和 FlashVars HTML 參數(僅適用于主 Application)的值。

?

?

?

接收參數代碼:

[javascript] view plaincopyprint?
  • privatefunction init():void?
  • {?
  • ??? if (parameters != null) {?
  • ??????? var source:String = parameters.source as String;?
  • ??????? var param2:String = parameters.test as String;?
  • ??? }?
  • }?
  • private function init():void{if (parameters != null) {var source:String = parameters.source as String;var param2:String = parameters.test as String;}}

    ?

    ??????? parameters 參數有兩個來源Url和FlashVars,分別介紹如下:

    新建一個Flex應用程序時會同時新建一個html頁面,Flex應用是嵌入到html中的。其中包括javascript和<noscript>標簽兩部分,只有當瀏覽器不支持javascript時才會執行<noscript>中的代碼。

    ??????? 1.通過url傳遞參數

    這種方式和html url傳參一樣,swf?param1=param1&param2=param2代碼如下:

    ?

    [javascript] view plaincopyprint?
  • swfobject.embedSWF(?
  • ??????????????? "VideoPlayer.swf?source=http://material.157you.com/material/767/dcf_enc.flv&param2=test", "flashContent",??
  • ??????????????? "500", "500",??
  • ??????????????? swfVersionStr, xiSwfUrlStr,??
  • ??????????????? flashvars, params, attributes);?
  • swfobject.embedSWF("VideoPlayer.swf?source=http://material.157you.com/material/767/dcf_enc.flv&param2=test", "flashContent", "500", "500", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes); [html] view plaincopyprint?
  • <noscript>?
  • ??? <objectclassid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"width="500"height="500"id="VideoPlayer">?
  • ????? <paramname="movie"value="VideoPlayer.swf?source=http://material.157you.com/material/767/dcf_enc.flv"/>?
  • ????? ......?
  • ????? <!--[if !IE]>-->?
  • ????? <objecttype="application/x-shockwave-flash"data="VideoPlayer.swf?source=http://material.157you.com/material/767/dcf_enc.flv&param2=test "width="500"height="500">?
  • ???????? .......?
  • ????? <!--<![endif]-->?
  • ????? ......?
  • ??? </object>?
  • <noscript>?
  • <noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="500" height="500" id="VideoPlayer"><param name="movie" value="VideoPlayer.swf?source=http://material.157you.com/material/767/dcf_enc.flv" />......<!--[if !IE]>--><object type="application/x-shockwave-flash" data="VideoPlayer.swf?source=http://material.157you.com/material/767/dcf_enc.flv&param2=test " width="500" height="500">.......<!--<![endif]-->......</object> <noscript>

    ??????? 2.通過FlashVars傳遞參數

    ?

    ?

    [javascript] view plaincopyprint?
  • var flashvars = {};?
  • flashvars.source = "http://material.157you.com/material/767/dcf_enc.flv";?
  • flashvars.param2 = "test";?
  • ?
  • swfobject.embedSWF(?
  • ??? "VideoPlayer.swf", "flashContent",??
  • ??? "500", "500",??
  • ??? swfVersionStr, xiSwfUrlStr,??
  • ??? flashvars, params, attributes);?
  • var flashvars = {};flashvars.source = "http://material.157you.com/material/767/dcf_enc.flv";flashvars.param2 = "test";swfobject.embedSWF("VideoPlayer.swf", "flashContent", "500", "500", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes); [html] view plaincopyprint?
  • <noscript>?
  • ??? <objectclassid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"width="500"height="500"id="VideoPlayer">?
  • ??????? <paramname="movie"value="VideoPlayer.swf"/>?
  • ??????? <paramname="flashvars"value="source=http://material.157you.com/material/767/dcf_enc.flv&param2=test"/>?
  • ???? ......?
  • ??????? <!--[if !IE]>-->?
  • ??????? <objecttype="application/x-shockwave-flash"data="VideoPlayer.swf"width="500"height="500">?
  • ??????????? <paramname="flashvars"value="source=http://material.157you.com/material/767/dcf_enc.flv&param2=test"/>?
  • ??????????? ......?
  • ??????? <!--<![endif]-->?
  • ??????? ......?
  • ??? </object>?
  • <noscript>?
  • <noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="500" height="500" id="VideoPlayer"><param name="movie" value="VideoPlayer.swf" /><param name="flashvars" value="source=http://material.157you.com/material/767/dcf_enc.flv&param2=test" />......<!--[if !IE]>--><object type="application/x-shockwave-flash" data="VideoPlayer.swf" width="500" height="500"><param name="flashvars" value="source=http://material.157you.com/material/767/dcf_enc.flv&param2=test" />......<!--<![endif]-->......</object> <noscript>

    注意:當同時使用url和flashvars傳參時,如果參數名相同則flashvars的值會覆蓋url的值

    ?

    ??????? 以上是通過Flex提供的專門傳遞參數的方式實現的,還有一種方式也可以實現參數傳遞,我們知道在Flex中可以調用JS的方法,所以可以在JS中寫一個方法,返回值為要傳遞的參數,這樣在Flex中就可以獲取到了,這算是曲線救國的一種方法。

    JS方法,返回參數params:

    [javascript] view plaincopyprint?
  • function flexParams() {?
  • ??? var params = {param2:'test'};?
  • ??? params.source = "http://material.157you.com/material/767/dcf_enc.flv";?
  • ?
  • ??? return params;?
  • }?
  • function flexParams() {var params = {param2:'test'};params.source = "http://material.157you.com/material/767/dcf_enc.flv";return params;}

    Flex中調用JS方法,獲得參數:

    ?

    [javascript] view plaincopyprint?
  • privatefunction init():void?
  • {?
  • ??? var params:Object = ExternalInterface.call("flexParams");?
  • ?????
  • ??? if (params != null) {?
  • ??????? var source:String = params.source as String;?
  • ??????? var param2:String = params.param2 as String;?
  • ??? }?
  • }?
  • private function init():void{var params:Object = ExternalInterface.call("flexParams");if (params != null) {var source:String = params.source as String;var param2:String = params.param2 as String;}}

    轉載于:https://www.cnblogs.com/regalys168/p/3627748.html

    總結

    以上是生活随笔為你收集整理的HTML向Flex传参的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。