一. swf?传参
html代码:
代码
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html charset=utf-8″ />
<title>as</title>
</head>
<body>
<object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0″ id=”testSWF” width=”550″ height=”400″ title=”test”>
<param name=”movie” value=”test.swf?sname=xxhui” />
<param name=”quality” value=”high” />
<embed src=”test.swf” quality=”high” pluginspage=”http://www.macromedia.com/go/getflashplayer” type=”application/x-shockwave-flash” width=”550″ height=”400″></embed>
</object>
</body>
</html>
<head>
<meta http-equiv=”Content-Type” content=”text/html charset=utf-8″ />
<title>as</title>
</head>
<body>
<object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0″ id=”testSWF” width=”550″ height=”400″ title=”test”>
<param name=”movie” value=”test.swf?sname=xxhui” />
<param name=”quality” value=”high” />
<embed src=”test.swf” quality=”high” pluginspage=”http://www.macromedia.com/go/getflashplayer” type=”application/x-shockwave-flash” width=”550″ height=”400″></embed>
</object>
</body>
</html>
Flash 代码一: (使用_root):
x_txt.text = _root.sname;
Flash 代码二:
代码
String.prototype.$_GET = function(Parameter:String) {
return (this.toLowerCase().split(Parameter.toLowerCase()+”=”)[1].split(”&”)[0]);
};
//获得URL中的user参数的值
var sname:String = this._url.$_GET(”sname”);
x_txt.text = sname;
return (this.toLowerCase().split(Parameter.toLowerCase()+”=”)[1].split(”&”)[0]);
};
//获得URL中的user参数的值
var sname:String = this._url.$_GET(”sname”);
x_txt.text = sname;
二. FlashVars传参
html代码:
代码
<object classid=”clsid:d27cdb6e-ae6d-11cf-96b8-444553540000″ codebase=”http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0″ width=”550″ height=”400″ id=”FlashVars” align=”middle”>
<param name=”allowScriptAccess” value=”sameDomain” />
<param name=”movie” value=”FlashVars.swf” />
<param name=”flashvars” value=”foo=happy2005&program=flash&language=简体中文-中国” />
<param name=”quality” value=”high” />
<param name=”bgcolor” value=”#ffffff” />
<embed src=”FlashVars.swf” quality=”high” bgcolor=”#ffffff” width=”550″ height=”400″ name=”FlashVars” align=”middle” allowScriptAccess=”sameDomain” FlashVars=”foo=happy2005&program=flash&language=简体中文-中国” type=”application/x-shockwave-flash” pluginspage=”http://www.macromedia.com/go/getflashplayer” />
</object>
<param name=”allowScriptAccess” value=”sameDomain” />
<param name=”movie” value=”FlashVars.swf” />
<param name=”flashvars” value=”foo=happy2005&program=flash&language=简体中文-中国” />
<param name=”quality” value=”high” />
<param name=”bgcolor” value=”#ffffff” />
<embed src=”FlashVars.swf” quality=”high” bgcolor=”#ffffff” width=”550″ height=”400″ name=”FlashVars” align=”middle” allowScriptAccess=”sameDomain” FlashVars=”foo=happy2005&program=flash&language=简体中文-中国” type=”application/x-shockwave-flash” pluginspage=”http://www.macromedia.com/go/getflashplayer” />
</object>
Flash代码:
通过上面的代码,在SWF(FlashVars.swf)中就可以直接获取foo、program、language变量数据。FlashVars.fla获取FlashVars参数的代码如下:
代码
// 创建三个文本字段
_root.createTextField(”foo_txt”,1,0,0,16,16);
_root.createTextField(”program_txt”,2,0,32,16,16);
_root.createTextField(”language_txt”,3,0,64,16,16);
foo_txt.autoSize = true;
foo_txt.border = true;
program_txt.autoSize = true;
program_txt.border = true;
language_txt.autoSize = true;
language_txt.border = true;
// 获取FlashVars变量
foo_txt.text = “HTML中的foo参数:”+foo;
program_txt.text = “HTML中的program参数:”+program;
language_txt.text = “HTML中的language参数:”+language;
_root.createTextField(”foo_txt”,1,0,0,16,16);
_root.createTextField(”program_txt”,2,0,32,16,16);
_root.createTextField(”language_txt”,3,0,64,16,16);
foo_txt.autoSize = true;
foo_txt.border = true;
program_txt.autoSize = true;
program_txt.border = true;
language_txt.autoSize = true;
language_txt.border = true;
// 获取FlashVars变量
foo_txt.text = “HTML中的foo参数:”+foo;
program_txt.text = “HTML中的program参数:”+program;
language_txt.text = “HTML中的language参数:”+language;