home > SWFObjectとFlashVars
SWFObjectとFlashVars
December 22, 2008
SWFObject v1.5の場合は
var so = new SWFObject("swf/main.swf", "main", "100%", "100%", "8", "#FFFFFF", true);
so.addVariable("FlashVars", "sample");
so.addParam("allowScriptAccess", "always");
〜
so.write("flashContentsBlock");
Flash側
var myname:String;
var flashVars:Object = this.root.loaderInfo.parameters;
myname = flashVars['sample'];
SWFObject v2.1の場合は
<head>
<script type="text/javascript" src="swfobject-2-1.js"></script>
<script type="text/javascript">
function createPlayer(thePlaceholder, thePlayerId, theFile, theAutostart) {
var flashvars = {
file:theFile,
autostart:theAutostart
}
var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
}
var attributes = {
id:thePlayerId,
name:thePlayerId
}
swfobject.embedSWF("player.swf", thePlaceholder, "320", "196", "9.0.115",
false, flashvars, params, attributes);
}
function init() {
createPlayer("placeholder1", "player1", "xxxxxx1.flv", false);
createPlayer("placeholder2", "player2", "xxxxxx2.flv", false);
createPlayer("placeholder3", "player3", "xxxxxx3", false);
}
</script>
</head>
でいけるみたい。忘れそうなのでメモ。
【追記】
URLにパラメーター付けてアクセスする時。
HTML側
so.addVariable("id", getQueryParamValue("id"));
Flash側のソースは下記になります。
import flash.display.*;
〜
var tmpParam:Object; = loaderInfo.parameters;
var id_numberString = String(tmpParam["id"]);
〜
参考サイト
http://www.link-log.net/archives/2007/07/htmlswf_2.html