Log in

View Full Version : External API - changing swf filename breaks everything?



jlizarraga
05-13-2008, 10:50 PM
I am using the External API in the most basic way possible: to play a movie when the page is finished loading.

Everything works just fine, but for some strange and mysterious reason, I can't change the filename of the swf I'm using.

Here is the simple js code:


// Flash External API Functions
function callExternalInterface() {
getMovieName("myMovie").callPlayBall();
}

function getMovieName(movieName) {
if (navigator.appName.indexOf("Microsoft") != -1) {
return window[movieName]
}
else {
return document[movieName]
}
}

And here's the html:


<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','980','height','385','src','images/homepage_loader','quality','high','wmode','opaque','allowScriptAccess','always','id','myMovie','name','myMovie','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','images/homepage_loader' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="980" height="385" id="myMovie" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="images/homepage_loader.swf" />
<param name="quality" value="high" />
<param name="wmode" value="opaque" />
<embed src="images/homepage_loader.swf" quality="high" wmode="opaque" name="myMovie" align="middle" allowScriptAccess="always" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="980" height="385"></embed>
</object></noscript>

And then there is the body onLoad calling the callExternalInterface function. This works great. But if I export the homepage_loader.fla as homepage_loader2.swf (and change all four references in the above code to match), I am greeted with a "callPlayBall is not a function" error.

The javascript is using the id/name of the swf to manipulate it, not the filename. Why would simply changing the filename of the swf cause my External API function to break? :confused:

In case it helps, I'm using CS3 with AS2.0.

jlizarraga
05-13-2008, 10:59 PM
Okay now it gets weirder.

If I put homepage_loader.swf into a different directory and change the file paths, everything still works fine.

If I change homepage_loader.swf's filename to homepage_loader2.swf and change the file paths, everything breaks.

That makes about 0 sense to me. ;-;

Medyman
05-13-2008, 11:03 PM
I'm not really sure. I've never ever seen that happen. The only thing that comes to mind is a possible cache issue. Have you tried clearning your system cache between tests?

jlizarraga
05-13-2008, 11:13 PM
I'm certain that it's not a cache issue. I am using the web developer toolbar with FF and have the cache disabled. Just in case I cleared my cache anyway and the error was still there. This happens in both FF and IE.

Trying to narrow the problem down further, it gets weirder still:

Using the fla that generated the original swf (the one that works with its original filename intact), I exported the movie as the exact same filename, and the newly exported version with the same filename did not work. Even their size in bytes is identical, yet the External API simply rejects the newer version?

These two files are identical in every way, but either the browsers or Flash are detecting some difference. The only difference is their creation date - they are the same damn file.

This is by far the strangest issue I've ever seen with Flash.

Medyman
05-13-2008, 11:24 PM
Is this happening in all browsers?

jlizarraga
05-13-2008, 11:26 PM
It happens in FF2, IE6, and IE7. Those are the only browsers I'm concerned with/have installed but if it happens in all 3 surely there is something going on here.