加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex4如何给html 中的swf传参数

发布时间:2020-12-15 04:16:22 所属栏目:百科 来源:网络整理
导读:基本上有3种方式:? 1)通过URL查询字符串方式给swf传参数? URL如下:? http://localhost:8080/html2Swf/bin-debug/html2Swf.swf ? myName=aamyHometown=aa? 2)通过URL查询字符串方式给swf的wrapper html页面传参数? http://localhost:8080/html2Swf/bin-debug
基本上有3种方式:?
1)通过URL查询字符串方式给swf传参数?

URL如下:?
http://localhost:8080/html2Swf/bin-debug/html2Swf.swf ? myName=aa&myHometown=aa?
2)通过URL查询字符串方式给swf的wrapper html页面传参数?
http://localhost:8080/html2Swf/bin-debug/html2Swf.html # firstName=Nick&lastName=Danfffger?
注意,第1中方式中用 ,第2中方式用 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 3)在对应的Wrapper html页面中静态配置,有两个地方可以配置:?
位置1 var flashvars = {};?

案例 var flashvars = {"myName":"Danger","myHometown":"Los%20Angeles_Flashvars"};?
位置2?
Java代码??

收藏代码

  1. swfobject.embedSWF(??
  2. ??????"${swf}.swf",?"flashContent",???
  3. ??????"${width}",?"${height}",250); line-height:18px"> ??????swfVersionStr,?xiSwfUrlStr,250); line-height:18px"> ??????flashvars,?params,?attributes);??

案例:?
??????"${swf}.swf?myName=aa&myHometown=bb",sans-serif; font-size:14px; line-height:25.1875px">综合案例?
按方式1和3传参数,只有上面的TitleWindow里面有值,其中方式3事实上就是不传参数,按方式2传参数,只有下面的TitleWindow里面有参数值.?
<?xml?version="1.0"?encoding="utf-8"?>??
  • <s:Application?xmlns:fx="http://ns.adobe.com/mxml/2009"???
  • ???????????????xmlns:s="library://ns.adobe.com/flex/spark"???
  • ???????????????xmlns:mx="library://ns.adobe.com/flex/mx"???
  • ???????????????creationComplete="initVars();init(event)"?minWidth="955"?minHeight="600">??
  • ????<s:layout>??
  • ????????<s:VerticalLayout/>??
  • ????</s:layout>??
  • ????<fx:Declarations>??
  • ????????<!--?Place?non-visual?elements?(e.g.,?services,?value?objects)?here?-->??
  • ????</fx:Declarations>??
  • ????<fx:Script>??
  • ????????<![CDATA[??
  • ????????import?mx.core.FlexGlobals;??
  • import?mx.core.mx_internal;??
  • ????????use?namespace?mx_internal;??
  • ????????//?Declare?bindable?properties?in?Application?scope.??
  • ????????[Bindable]??
  • public?var?myName:String;??
  • public?var?myHometown:String;??
  • ??????????
  • //?Assign?values?to?new?properties.??
  • private?function?initVars():void?{??
  • ????????????myName?=?FlexGlobals.topLevelApplication.parameters.myName;??
  • ????????????myHometown?=?FlexGlobals.topLevelApplication.parameters.myHometown;??
  • ????????}??
  • import?mx.managers.BrowserManager;??
  • import?mx.managers.IBrowserManager;??
  • import?mx.utils.URLUtil;??
  • private?var?bm:IBrowserManager;??
  • private?var?fName:String;??
  • private?var?lName:String;???????????
  • private?function?init(e:Event): ????????????bm?=?BrowserManager.getInstance();??
  • ????????????bm.init("",?"Welcome!");??
  • ??????????????
  • ????????????/*?The?following?code?will?parse?a?URL?that?passes?firstName?and?lastName?as?
  • ????????????query?string?parameters?after?the?"#"?sign;?for?example:?
  • ????????????http://www.mydomain.com/MyApp.html#firstName=Nick&lastName=Danger?*/??
  • ????????????var?o:Object?=?URLUtil.stringToObject(bm.fragment,?"&");??
  • ????????????fName?=?o.firstName;??
  • ????????????lName?=?o.lastName;??
  • ??
  • ????]]>??
  • ????</fx:Script>??
  • ??????
  • ????<mx:TitleWindow?title="Passing?variables?to?swf?directly">??
  • ????????<mx:HBox>??
  • ????????????<mx:Label?text="Name:?"/>??
  • ????????????<mx:Label?text="{myName}"?fontWeight="bold"/>??
  • ????????</mx:HBox>??
  • ????????????<mx:Label?text="Hometown:?"/>??
  • ????????????<mx:Label?text="{myHometown}"?fontWeight="bold"/>??
  • ????</mx:TitleWindow>??
  • ????<mx:TitleWindow?title="Passing?variables?to?swf?through?wrapper?html">??
  • ????????<mx:Form>??
  • ????????????<mx:FormItem?label="First?name:">??
  • ????????????????<mx:Label?id="ti1"?text="{fName}"/>??
  • ????????????</mx:FormItem>??
  • ????????????<mx:FormItem?label="Last?name:">??
  • ????????????????<mx:Label?id="ti2"?text="{lName}"/>??
  • ????????</mx:Form>??
  • </s:Application> ?
  • (编辑:李大同)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读