使用Flash Builder 4创建Flex应用,会自动生成网页调用Flash,会有两种方式显示Flash,下面针对这两个方式看看如何添加参数。
方式一(swfobject):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
<script type=
"text/javascript"
>
<!-- For version detection,
set
to min. required Flash Player version,or
0
(or
0.0
.
0
),255)!important; background:none!important">for
no version detection. -->
var
swfVersionStr =
"10.0.0"
;
<!-- To
use
express install,monospace!important; min-height:inherit!important; background:none!important">to playerProductInstall.swf,otherwise the empty string. -->
xiSwfUrlStr =
"playerProductInstall.swf"
;
<span style=
"color: #000000;"
>
flash
var
s = {
1:
"abc"
,
2:
"def"
};
</span>
params = {};
attributes = {};
attributes.id =
"test39"
;
attributes.name =
;
attributes.align =
"middle"
;
swfobject.embedSWF(
"test39.swf"
ottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.8em!important; margin:0px!important; outline:rgb(0,
"flashContent"
ottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.8em!important; margin:0px!important; outline:rgb(0,
"100%"
ottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.8em!important; margin:0px!important; outline:rgb(0,
swfVersionStr,xiSwfUrlStr,
s,params,attributes);
<!-- JavaScript enabled so display the flashContent div
in
case
it
is
not replaced
with
a swf object. -->
</script>
|
方式二(html):
<object classid=
"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
width=
"100%"
height=
id=
<param name=
"movie"
value=
"demo1.swf"
/>
"quality"
"high"
/>
"bgcolor"
"#ffffff"
/>
"allowScriptAccess"
"sameDomain"
/>
"allowFullScreen"
"true"
/>
</span> <!--[
if
!IE]>-->
<object type=
"application/x-shockwave-flash"
data=
>
/>
/>
/>
/>
/>
<!--<![endif]-->
<!--[
gte IE
6
]>-->
<p>
Either scripts and active content are not permitted to run or Adobe Flash Player version
10.0
or greater
not installed.
</p>
<!--<![endif]-->
<a href=
"http://www.adobe.com/go/getflashplayer"
>
<img src=
"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
alt=
"Get Adobe Flash Player"
/>
</a>
!IE]>-->
</object>
<!--<![endif]-->
</object>
|
在Flash中接收网页传递过来的参数
<?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"
minWidth=
"955"
minHeight=
"600"
creationComplete=
"application1_creationCompleteHandler(event)"
pageTitle=
>
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import
mx.core.FlexGlobals;
mx.events.FlexEvent;
protected
function
application1_creationCompleteHandler(event:FlexEvent):
void
{
</span> text1.text = para.
1;
text2.text = para.
2;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<s:TextInput id=
"text1"
x=
"190"
y=
"93"
/>
"text2"
"142"
/>
<s:Label x=
"147"
"94"
text=
"var1:"
/>
"142"
"var2:"
/>
</s:Application>
|
参数在Flex4的获取方式跟Flex3是不一样的:
Flex3: var params:Object = Application.application.parameters;
Flex4: var params:Object = FlexGlobals.topLevelApplication.parameters;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。