PDA

View Full Version : Firefox and MM_controlShockwave() - BROKEN


beau
03-08-2006, 02:52 PM
I'm trying to control a swf using the good old Dreamweaver/Macromedia functions:

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0
var obj=MM_findObj(objStr);
if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?fr ameNum:'')+')');
}

And here's the function call:
MM_controlShockwave('swf_ps','','StopPlay');
when the page loads, and then
MM_controlShockwave('swf_ps','','Play');
when I'm ready for it to start playing.

Which of course works great in IE, but Firefox is shooting the pooch.

The JS error is:
obj.StopPlay is not a function

I'm almost sure there's a solution out there, but I can't find anything.
- Yes, I need javascript to control the swf,
- no, I can't use FSCommand because I am not designing some of the swf files - only implementing them.

Here's the thing - I'm able to write the swf to the page and set the param "PLAY" to FALSE, so then, isn't there a way to go back and set it to true?

beau
03-08-2006, 10:57 PM
Hey I found a solution, here it is:

function MM_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0
f = getFlashMovieObject(objStr);
if(f!=null && f!=undefined){
if(cmdName=="Play"){
eval('f.' + cmdName + '();');
} else {
eval('f.' + cmdName);
}
}
}

function getFlashMovieObject(movieName){
if (window.document[movieName]){
return window.document[movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1){
if (document.embeds && document.embeds[movieName]){
return document.embeds[movieName];
}
}
else{
return document.getElementById(movieName);
}
}

But this only controls Play and StopPlay.