2006年02月23日
Flash 8 を JavaScriptから操作
( Flash 7 以降)
( Flash 8 以降)
Flash はあまり詳しく無いです。ムービーは全く解らないので、
パーツとして限定利用しています。
<SCRIPT language="JavaScript">
function getVersionFromSWF() {
var obj;
if ( document.all ) {
obj = document.getElementById("flash1");
}
else {
obj = document.getElementById("flash2");
}
obj.SetVariable("commandType", "getVersion");
obj.Play();
}
function setClipboard( strValue ) {
var obj;
if ( document.all ) {
obj = document.getElementById("flash1");
}
else {
obj = document.getElementById("flash2");
}
obj.SetVariable("commandType", "setClipboard");
obj.SetVariable("paramValue", strValue );
obj.Play();
}
function urlDownload( ) {
var obj;
if ( document.all ) {
obj = document.getElementById("flash1");
}
else {
obj = document.getElementById("flash2");
}
obj.SetVariable("commandType", "urlDownload");
obj.SetVariable("paramValue", "http://自ドメインファイル" );
obj.SetVariable("paramValue2", "ローカルファイル名" );
obj.Play();
}
function flash1_DoFSCommand(commandType, result) {
if ( commandType == 'onProgress' ) {
document.getElementsByName("disp")[0].value =
result;
}
else {
alert(commandType + ":" + result)
}
}
function utilWeblog_DoFSCommand(commandType, result) {
if ( commandType == 'onProgress' ) {
document.getElementsByName("disp")[0].value =
result;
}
else {
alert(commandType + ":" + result)
}
}
</SCRIPT>
<SCRIPT language="VBScript">
Sub flash1_FSCommand(commandType, result)
Call flash1_DoFSCommand(commandType, result)
End Sub
</SCRIPT>
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=shift_jis">
<SCRIPT language="JavaScript">
</SCRIPT>
</HEAD>
<BODY>
<OBJECT
id="flash1"
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
width=0
height=0
>
<PARAM name="movie" value="utilWeblog.swf">
<PARAM name="allowScriptAccess" value="always">
<EMBED
id="flash2"
name="utilWeblog"
swliveconnect="true"
src="utilWeblog.swf"
width=0
height=0
type="application/x-shockwave-flash"
>
</OBJECT>
<INPUT
type=button
value="getVersionFromSWF"
onClick="getVersionFromSWF();"><br><br>
<INPUT
type=button
value="setClipboard"
onClick="
setClipboard( document.getElementsByName('data')[0].value );
">
<INPUT type=text name="data"><br><br>
<INPUT
type=button
value="urlDownload"
onClick="urlDownload();">
<INPUT type=text name="disp"><br><br>
</BODY>
</HTML>
