Hi EveryOne, I am trying to use ExternalInterface Class to provide communication between actionscript 2.0
and JavaScript. But I am not able to achieve that.
Following is the code that i used.
Code in FlaFile.fla is as follows:
import flash.external.*;
this.createEmptyMovieClip("mc",this.getnexthighestdepth())
flash.external.ExternalInterface.addCallback("fnGetVar", fnGetVar);
function fnGetVar(nn: String ):String {
nn = "100";
return ("hai");
}
if(ExternalInterface.available)
{
with (mc)
{
beginFill (0xFFFFFF);
lineStyle(4, 0x0000FF, 100);
moveTo( 0, 0);
lineTo (0, 0);
lineTo (0, 20);
lineTo (20, 20);
lineTo (20, 0);
endFill ();
}
}
Code in FlaFile.html is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-
transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script>
function fnCall()
{
alert(1);
try{
//var flashMovie = window.document.FlaFile;
alert(FlaFile);
var newVar=FlaFile.fnGetVar("value");
alert(newVar);
}
catch(e)
{
alert("error"+e.message);
}
}
</script>
<title>FlaFile</title>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<input type="button" value="click!!!" onclick="fnCall()">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve rsion=7,0,0,0"
width="550" height="400" id="FlaFile" name="FlaFile" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="FlaFile.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="FlaFile.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="FlaFile"
id="FlaFile" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>
Can Somebody tell me where it is going wrong?
The error which i am getting in IE9 is "Object doesn't support property or method 'fnGetVar'" and the
error which i am getting in Chrome is "Object #<HTMLCollection> has no method 'fnGetVar'" and in firefox
the error is "FlaFile is not defined"
fla Editor which i am using is Macromedia Flash MX Professional 2004 Version 7.0
North America
Europe, Middle East and Africa
Asia Pacific