html、aspx与flash as3传参

3 篇文章 0 订阅
1 篇文章 0 订阅

首先将Flash嵌到html或aspx页面,然后使用flashvars在flash里获取html或aspx传来的参数(参数:user、password),

1).aspx页面代码:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Flash.aspx.cs" Inherits="Web.Flash" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Main</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
html, body {
	height:100%;
	background-color: #ffffff;
}
body {
	margin:0;
	padding:0;
	overflow:hidden;
}
#flashContent {
	width:100%;
	height:100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
  <div id="flashContent">
    <center>
      <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="as3aspx" align="middle">
        <param name="movie" value="as3aspx.swf" />
        <param name="quality" value="autohigh" />
        <param name="bgcolor" value="#333333" />
        <param name="play" value="true" />
        <param name="loop" value="true" />
        <param name="wmode" value="window" />
        <param name="scale" value="showall" />
        <param name="menu" value="true" />
        <param name="devicefont" value="false" />
        <param name="salign" value="" />
        <param name="flashvars" value="user=p333&password=111111" /><!--支持在IE浏览器里获取参数-->
        <param name="allowScriptAccess" value="sameDomain" />
        <param name="allowFullScreen" value="true" />
        <!--[if !IE]>-->
		<object type="application/x-shockwave-flash" data="as3aspx.swf" width="980" height="735">
		<param name="movie" value="as3aspx.swf" />
		<param name="quality" value="autohigh" />
		<param name="bgcolor" value="#000000" />
		<param name="play" value="true" />
		<param name="loop" value="true" />
		<param name="wmode" value="window" />
		<param name="scale" value="showall" />
		<param name="menu" value="true" />
		<param name="devicefont" value="false" />
		<param name="salign" value="" />
        <!--传参-->
        <param name="flashvars" value="user=p333&password=111111" /><!--支持在 非 IE浏览器里获取参数-->
		<param name="allowScriptAccess" value="sameDomain" />
		<param name="allowFullScreen" value="true" />
		<!--<![endif]-->
        <a href="http://www.adobe.com/go/getflash"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="获得 Adobe Flash Player" /> </a>
        <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
      </object>
    </center>
  </div>
</form>
</body>
</html>

2).html页面代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Main</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
html, body {
	height:100%;
	background-color: #ffffff;
}
body {
	margin:0;
	padding:0;
	overflow:hidden;
}
#flashContent {
	width:100%;
	height:100%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
  <div id="flashContent">
    <center>
      <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="400" id="as3html" align="middle">
        <param name="movie" value="as3html.swf" />
        <param name="quality" value="autohigh" />
        <param name="bgcolor" value="#333333" />
        <param name="play" value="true" />
        <param name="loop" value="true" />
        <param name="wmode" value="window" />
        <param name="scale" value="showall" />
        <param name="menu" value="true" />
        <param name="devicefont" value="false" />
        <param name="salign" value="" />
        <param name="flashvars" value="user=p333&password=111111" /><!--支持在IE浏览器里获取参数-->
        <param name="allowScriptAccess" value="sameDomain" />
        <param name="allowFullScreen" value="true" />
        <!--[if !IE]>-->
		<object type="application/x-shockwave-flash" data="as3html.swf" width="980" height="735">
		<param name="movie" value="as3html.swf" />
		<param name="quality" value="autohigh" />
		<param name="bgcolor" value="#000000" />
		<param name="play" value="true" />
		<param name="loop" value="true" />
		<param name="wmode" value="window" />
		<param name="scale" value="showall" />
		<param name="menu" value="true" />
		<param name="devicefont" value="false" />
		<param name="salign" value="" />
        <!--传参-->
        <param name="flashvars" value="user=p333&password=111111" /><!--支持在 非 IE浏览器里获取参数-->
		<param name="allowScriptAccess" value="sameDomain" />
		<param name="allowFullScreen" value="true" />
		<!--<![endif]-->
        <a href="http://www.adobe.com/go/getflash"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="获得 Adobe Flash Player" /> </a>
        <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
      </object>
    </center>
  </div>
</form>
</body>
</html>

3).flash as3.0代码:

 

var str1:String =stage.loaderInfo.parameters["user"]; //var str1:String =stage.loaderInfo.parameters.user;
var str2:String =stage.loaderInfo.parameters["password"]; //var str2:String =stage.loaderInfo.parameters.password; 
//vars_txt为flash里的实例;
vars_txt.text="user name:"+ str1 +" "+"password:" + str2;


 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值