createSWF 动态发布和浏览器通信
使用 SWFObject 公开的内部方法来加载 Flash。
function AStoJSviaExternalInterface(str) {
document.getElementById('receive1').value = str;
};
function myCom_DoFSCommand(command, args) {
document.getElementById('receive2').value = args;
};
function AStoJSviaGetURL(str) {
document.getElementById('receive3').value = str;
};
if (swfobject.hasFlashPlayerVersion('9.0.0')) {
var fn = function() {
var att = {
data: 'swf/test8_com.swf',
width: '300',
height: '120',
id: 'myCom',
name: 'myCom'
};
var par = {
swliveconnect: 'true'
};
var id = 'myContent';
var o = swfobject.createSWF(att, par, id);
document.getElementById('but1').onclick = function() {
if (o && typeof o.JStoASviaExternalInterface != 'undefined') {
o.JStoASviaExternalInterface(document.getElementById('send').value);
};
};
document.getElementById('but2').onclick = function() {
if (o && typeof o.SetVariable != 'undefined') {
o.SetVariable('JStoASviaSetVariable', document.getElementById('send').value);
};
};
};
swfobject.addDomLoadEvent(fn);
};