Hi folks,
i have little problem, i am trying to communicate from javascript to AS3 by using External Interfaces, now the problem is that the function i am trying to call works fine with Internet Explorer 8, but it doesn’t works with firefox 3.5.9 or google chrome, below is the html / javascript code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">
swfobject.registerObject("chatApplication", "9.0.0");
</script>
</head>
<body>
<script type="text/javascript">
var currentUser="someuser";
//function that get called by clicking on a link / button
function setCurrentUser(newUser)
{
//alert(currentUser);
currentUser = newUser;
SendDataToFlashMovie(currentUser);
}
// function that get the required flash movie from the page
//you need to pass in the embed id of swf file which in this
//case is "myFlashConten".
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 if (navigator.appName.indexOf("Microsoft Internet")!=-1)
{
return document.getElementById(movieName);
}
}
//the actual function that will call function inside flash player
function SendDataToFlashMovie(newUser){
var test=getFlashMovieObject("chatApplication");
alert(test);
test.SendUserName(newUser);
}
</script>
<div>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="950" height="650" id="chatApplication">
<param name="movie" value="chatApp.swf" />
<param name="allowscriptaccess" value="always" />
<param name="allownetworking" value="all" />
<param name="flashvars" value="username=iamuser1" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="chatApp.swf" width="950" height="650">
<param name="allowscriptaccess" value="always" />
<param name="allownetworking" value="all" />
<param name="flashvars" value="username=iamuser1" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflashplayer">
<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>
<a href="javascript:void(0);" onClick="setCurrentUser('iamuser2')">Set Current User</a>
</body>
</html>