In addition to what @bFunc mentioned, I might advise doing your onclick
event outside of the anchor tag, if possible. I find it best to target your elements that receive action via JS rather than embedded in the HTML code. This way, you can wrap the flashObj.changeText
call in a try/catch
to avoid JS errors (which may happen), and handle the error appropriately (i.e. if your SWF isn't available or loaded, like when a user doesn't have Flash Player installed).
For example:
HTML Code:
<a id="flash_bridge_link" href="#" onclick="javascript:void(0)">Click Me</a>
Javascript:
var flashLink = document.getElementById("flash_bridge_link");
var flashObj = document.getElementById("flashObject");
flashLink.onclick = function () {
try {
flashObj.changeText("it works!");
} catch (error) {
// Handle error as needed.
}
}
Hope it helps!