Hi guys,
I have a SWF file emedded withing a HTML page. Trying to do a simple operation - go to and play certain frame in SWF using javascript. I'm using ExternalInterface to do this but for the life of me can't get the two to communicate.
I add all the code but when clicking on the link which calls javascript, it says my flash object is undefined?
Here's the ActionScript code:
import flash.external.*;
function getFromJavaScript(frame:int):void
{
gotoAndPlay(frame);
}
ExternalInterface.addCallback("sendtoFlash",getFromJavaScript);
Here's the javascript:
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);
}
}
function sendtoSwf(numb)
{
var flashMovie = getFlashMovieObject("tour-flash");
flashMovie.sendToFlash(numb);
}
And here is the embedded SWF:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="600" height="335" id="tourFlash" align="middle">
<param name="movie" value="/media/Assets/Flash/tourFlash.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="/media/Assets/Flash/tourFlash.swf" width="600" height="335">
<param name="movie" value="/media/Assets/Flash/tourFlash.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
Any ideas? I'm totally stumped! For an example of problem, have a look here: http://www.onehealthfitness.com.au/get-started/virtual-tour.aspx
Thanks :)