So my team’s project has an swf embedded in JavaScript, we’re actually using java servlet’s to create the html/JavaScript. I am attempting to use as3’s ExternalInterface to add a callback which would get called in the javascript but everything I have tried will not work.
Here is some of the related code:
Javascript:(remember using servlets thats why this is all inside a string)
<html>
<head>
<script src='/oddmanor/AC_OETags.js' language='javascript'></script>
<script language='JavaScript' type='text/javascript'>
var requiredMajorVersion = 10;
var requiredMinorVersion = 1;
var requiredRevision = 0;
</script>
</head>
<body marginwidth='0' marginheight='0' leftmargin='0' topmargin='0'>
<script language='JavaScript' type='text/javascript'>
var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
if (hasReqestedVersion) {
AC_FL_RunContent(
'src', 'http://localhost:8080/download/FlashClient',
'width', '760',
'height', '600',
'align', 'middle',
'id', 'myswf',
'quality', 'high',
'bgcolor', '#FFFFFF',
'name', 'myswf',
'allowScriptAccess','always',
'type', 'application/x-shockwave-flash',
'codebase', 'http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab',
'pluginspage', 'http://www.adobe.com/go/getflashplayer',
'wmode', 'opaque',
'flashvars', 'challenge=c0oC5CjXjOpRagA0Eh0xi2uYCv-8HZfz-XpG2CCmJHZMnFQK8wYI4kultTUGYGff3N8-5lco_TrR2MfCvnUhVUyCOII6Xtem2rRIPD3SBJ18YxUSkH2GykI78Im2pfqw-UR44OqlOuZGafL3VRkn7KSiMm-AWbZt60MFHzHFaeEhIQke9aj04UkmaJL1MWoOU4CklVxoqX-ag146KilHEroL46JxcD9TLvCW9MG_Gv9fTAYOZK2_FEsHUMg0kP8WjyheWBftNxOuZoHQ9bIsB9EDe9pR4RwZryCjyL6p4T7Si0dMFfmEvml5mkhRYG74yj7pLDKTgHJeURUKOYY9RU9mFbsA82Q8-7cXeGlvQnk'
);
} else {
var alternateContent = 'Alternate HTML content should be placed here.<BR>'
+ 'This content requires the Adobe Flash Player. '
+ '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
document.write(alternateContent);
}
</script>
<noscript>
<div align="middle" id="swf">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param name="src" value="http://localhost:8080/download/FlashClient">
<param name="width" value="760">
<param name="height" value="600">
<param name="align" value="middle">
<param name="id" value="myswf">
<param name="quality" value="high">
<param name="bgcolor" value="#FFFFFF">
<param name="name" value="myswf">
<param name="allowScriptAccess" value="always">
<param name="type" value="application/x-shockwave-flash">
<param name="codebase" value="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="pluginspage" value="http://www.adobe.com/go/getflashplayer">
<param name="wmode" value="opaque">
<param name="flashvars" value="challenge=c0oC5CjXjOpRagA0Eh0xi2uYCv-8HZfz-XpG2CCmJHZMnFQK8wYI4kultTUGYGff3N8-5lco_TrR2MfCvnUhVUyCOII6Xtem2rRIPD3SBJ18YxUSkH2GykI78Im2pfqw-UR44OqlOuZGafL3VRkn7KSiMm-AWbZt60MFHzHFaeEhIQke9aj04UkmaJL1MWoOU4CklVxoqX-ag146KilHEroL46JxcD9TLvCW9MG_Gv9fTAYOZK2_FEsHUMg0kP8WjyheWBftNxOuZoHQ9bIsB9EDe9pR4RwZryCjyL6p4T7Si0dMFfmEvml5mkhRYG74yj7pLDKTgHJeURUKOYY9RU9mFbsA82Q8-7cXeGlvQnk">
<embed src="http://localhost:8080/download/FlashClient" width="760" height="600" align="middle" id="myswf" quality="high" bgcolor="#FFFFFF" name="myswf" allowScriptAccess="always" type="application/x-shockwave-flash" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="opaque" flashvars="challenge=c0oC5CjXjOpRagA0Eh0xi2uYCv-8HZfz-XpG2CCmJHZMnFQK8wYI4kultTUGYGff3N8-5lco_TrR2MfCvnUhVUyCOII6Xtem2rRIPD3SBJ18YxUSkH2GykI78Im2pfqw-UR44OqlOuZGafL3VRkn7KSiMm-AWbZt60MFHzHFaeEhIQke9aj04UkmaJL1MWoOU4CklVxoqX-ag146KilHEroL46JxcD9TLvCW9MG_Gv9fTAYOZK2_FEsHUMg0kP8WjyheWBftNxOuZoHQ9bIsB9EDe9pR4RwZryCjyL6p4T7Si0dMFfmEvml5mkhRYG74yj7pLDKTgHJeURUKOYY9RU9mFbsA82Q8-7cXeGlvQnk" />
</object>
This content requires the Adobe Flash Player and a browser with JavaScript enabled.
<a href='http://www.adobe.com/go/getflash/'>Get Flash</a>
</div>
</noscript>
<div>
<a href='http://d1fjc9whyjwawe.cloudfront.net/KingX_Studios_Terms_of_Service.pdf' TARGET='_blank'>KingX Terms of Service</a> |
<a href='http://d1fjc9whyjwawe.cloudfront.net/Privacy_Policy_Odd_Manor.pdf' TARGET='_blank'>Privacy Policy</a> |
<a href='http://www.activeboard.com/forum.spark?aBID=138536&topicID=42164567&p=3' TARGET='_blank'>Report a Bug</a>
</div>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<script type='text/javascript'>
FB.init(
{
'appId': '191461020878253',
'status': true,
'cookie': true,
'channelUrl': 'http://nimbus.com:8080/oddmanor/fb_channel.html'
}
);
var callback = function(data) {
var res;
if (data['order_id']) {
res = true;
}
else {
res = false;
}
var me;
if (navigator.appName.indexOf('Microsoft') != -1) {
me = window['myswf'];
}
else {
me = document['myswf'];
}
me.onPurchaseCompletion(res);
};
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName]; }
function getFriendsUsingApp()
{
alert("ALERRRRRT!!!");
getFlashMovie("myswf").passFriendArrayToFlash();
return "set2";
}
function makePurchase(objectInfo) {
var obj = {
'method': 'pay',
'order_info': objectInfo,
'purchase_type': 'item'
};
FB.ui(obj, callback);
}
</script>
</body>
</html>
Also I ripped out a bit of JavaScript code that didnt have anything to do with this problem(hopefully) so if there is a missing tag or something that’s probably not my problem.
NOTE I embed this correctly and get into the swf allowing it to call javascript functions(as3 calls the getStuff fn), using the ExternalInterface, which works but JS->as3 does NOT work ='(.
Other notes,
FlashClient is the name of the swf….
I cant use the movie object for anything (the return value of getFlashMovie), if I try to use no code after works…
The action script code calls the external interface addCallback function correctly(called in a try catch that’s how I know)
if(External…Availible)
External…addCallback(“passStuff”, as3PassStuff)
The only things I can think of;
1) The embed code isnt creating the object correctly, since I cant use the movie for anything
2) my swf is being created weird and doesnt allow script access.
We are using FlashBuilder to build the swf.
in my swf and we’re good.