I see there's questions on this already, however after looking through all those and matching my code I can't get the right effect. I'm trying to call a simple AS3 method from JS.
As below:
AS3:
private function InitialiseCallbacks():void
{
ExternalInterface.call("FlashReady");
ExternalInterface.addCallback("ReturnMall", ReturnToMall);
}
public function ReturnToMall():void
{
trace("ReturnMall: WORKED"); // Not being called
this.mall_map.visible = false;
}
Javascript:
function FlashReady()
{
swf = document.getElementById("CaviaGame");
console.log(swf);
}
function ShoppingMallClicked()
{
$(".shoppingmallbtn").effect("shake", { times:3 }, 5);
console.log(swf);
swf.ReturnMall();
}
<div align="center" id="flashContent">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="760" height="760" name="CaviaGame" id="CaviaGame" align="top">
<param name="movie" value="CaviaGame.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 value="true" name="swLiveConnect" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="always" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="CaviaGame.swf" width="760" height="760">
<param name="movie" value="CaviaGame.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 value="true" name="swLiveConnect" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="always" />
<!--<![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>
</div>
Javascript Console:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="760" height="760" name="CaviaGame" id="CaviaGame" align="top">
Uncaught TypeError: undefined is not a function
From what I can see it recognises the reference to my swf, but doesn't recognise that there's a function in it, or is failing to call it. I've done a callback from AS3 to Javascript, which calls successfully before retrieving the reference to the swf. However upon calling the function it still doesn't work.
I allowed access in the swfObject in html, I also tried Security.allowDomain() in the AS3 as well to no avail.
I haven't created this entire project myself, however I see this code in the project:
public function initializeMapViewerModule()
{
global.GameMode = "LoadingMapViewer";
// Initiate MapViewer Load
var queue:LoaderMax = new LoaderMax({name:"MapViewerQueue", onComplete:onLoadMapViewerModule});
queue.append( new SWFLoader("CaviaMapViewer.swf", {name:"CaviaMapViewer", estimatedBytes:5000, x:0, autoPlay:false}) );
queue.load();
} // END - initializeMapViewerModule
Could this possibly be another swf to the referenced one, which contains the code? Or would it be all being called from the swfObject put in from the html? If it's another how would I reference it?
Any advice appreciated as I've really searched heavy for this and am stumped.
Thanks!