Referencing The Html Object That Made The Externalinterface.call To The Javascript Function Called
i apologize if my terminology is off, my actionscript skills are pretty weak sauce. so, i have some actionscript that makes a ExternalInterface.call('someFunction'); call. is it po
Solution 1:
I guess you are talking about ExternalInterface.objectID. This property returns an id associated with flash container in object or embed tag.
I suggest that you should also pass the name of "someCallback" to you JS method. This way there will be no need to hardcode it in JS.
Here's an example
// Actionscript sourceconstjsMethodName:String = "someFunction";
constasCallbackName:String = "someCallback";
ExternalInterface.call(jsMethodName+"(document.getElementById("++")"++");");
ExternalInterface.addCallback(asCallbackName,someASfunction);
// Javascript sourcefunctionsomeFunction(flashId, callbackName)
{
var flashContainer = document.getElementById(flashId);
flashContainer["callbackName"]();
}
EDIT: If you really want to get a reference to flash DOM object in someFunction arguments, you may achieve it in a bit tricky way (I would rather not, but just for your interest).
// Actionscript sourceconstjsMethodName:String = "someFunction";
constasCallbackName:String = "someCallback";
ExternalInterface.addCallback(asCallbackName,someASfunction);
ExternalInterface.call(
"function(){"+
jsMethodName+"("+
"document.getElementById('"+ExternalInterface.objectID+"'),"+
"'"+asCallbackName+"'"+
");"+
"}"
);
// Javascript sourcefunctionsomeFunction(flashContainer, callbackName)
{
flashContainer[callbackName]();
}
This way you inject some JS code from flash into js. It works, but looks messy.
Post a Comment for "Referencing The Html Object That Made The Externalinterface.call To The Javascript Function Called"