using ExternalInterface to pass AS -> JS
I'm trying something different, seems like ExternalInterface API might be my answer to send a button name to my form POST.
In my SWF for my button I have this:
Code:
set ("buttonPressed", "pest");
import flash.external.ExternalInterface;
// Register so that it is possible to call from JavaScript in containing HTML
ExternalInterface.addCallback("getBtnName", null, getBtnName);
submitBtn.addEventListener("click", clickListener);
function clickListener(eventObj:Object):Void {
ExternalInterface.call("getFlashBtn", buttonPressed);
getURL("javascript:flashFormSubmit();");
}
getFlashBtn() is a function in my html form page:
Code:
var foo = null;
function getFlashBtn(btnname) {
foo = btnname;
}
function flashFormSubmit()
{
var myForm = document.forms[0];
var bn = document.getElementById('bname');
bn.value = foo;
myForm.submit();
}
as you can see I then send the buttonname that was supposedly sent by AS to a textfield, and then post the form using getUrl() with my js function.
Problem is, my form is not submitting. It seems the eventlistener is not firing. "submitBtn" is the instance name of my button. I'm not sure what is wrong, any ideas?
Tom