Accessibility

TechNote

Using ExternalInterface within a <form> tag causes communication between JavaScript and ActionScript to fail

Issue


Communication between JavaScript and ActionScript fails if a Flash or Flex movie uses ExternalInterface inside a form tag in Internet Explorer. The following error is displayed when you load, refresh, or close the page, or when you close the browser:

Error: [flash_movie_id] is undefined.

This issue also occurs with the Flex AJAX Bridge (FABridge), which uses the ExternalInterface. A .swf file placed inside a <form> tag will not be accessible through FABridge functions and will fail to load due to the initialization functions that are called automatically.

The following code sample uses ExternalInterface within a form tag and will return the above error message:

 <form>
		
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','width','796','height','200','id','sample','align','middle','src','externalinterface','allowscriptaccess','always','quality','high','bgcolor','#ffffff','name','sample','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','externalinterface' ); //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=7,0,19,0" >
<param name="movie" value="externalinterface.swf" />
<param name="quality" value="high" />
<embed href="externalinterface.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ></embed>
</object></noscript>
</form>

Solution


Solution 1: Use JavaScript to create the required reference to your Flash movie in the window object.

Add the following script after the embedded Flash movie:

window.[flash_movie_id] = document.forms[0].[flash_movie_id] ;

For example, if your flash_movie_id is called "sample" you would use the following:

<script type="text/javascript">window.sample = document.forms[0].sample;</script>

Solution 2: Add a nested form tag after the first form tag in the page.

For the sample code above, add <form></form> after the existing form tag, like this:

 <form><form></form>
		
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0','width','796','height','200','id','sample','align','middle','src','externalinterface','allowscriptaccess','always','quality','high','bgcolor','#ffffff','name','sample','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','externalinterface' ); //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=7,0,19,0" >
<param name="movie" value="externalinterface.swf" />
<param name="quality" value="high" />
<embed href="externalinterface.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ></embed>
</object></noscript>
</form>

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support


Document Details

ID:kb400730

Products Affected:

flash
flashplayer
flex