I’m calling a JS function with ExternalInterface.call and trying to get a return value inside Flash. When I trace out the op variable I get 0 instead of 500. Is there something wrong with my embed code?
Embed code:
<embed src="/sites/default/files/flash/flashgame/Preload.swf" width="975" height="572" align="middle" FlashVars="entry=login" quality="high" bgcolor="#ffffff" name="slider" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
JS:
function get_current_points(){
// Hardcoded return value for testing
return 500;
}
Actionscript:
var op:Number = ExternalInterface.call("get_current_points") as Number;
@knuckfubuck, I think your are not using the correct function name as pointed out by RobertBak. Otherwise the code is perfectly fine when I run it on my m/c.
@OXMO456, ‘as Number’ has nothing to do with this problem. In this case both ‘Number(Ext….)’ and ‘ Ext.. as Number’ are working fine.
Hope it helps,
Ashine.
===============================================================================
@khuckbuck in response to your comment, I am sure the function is not getting visible in Flex. Try using ‘if (ExternalInterface.available)’ inside flex to check if the interface is accessible to flex. This will help us pin pointing the problem.