as3 ExternalInterface.addCallback is not working right

I was trying to access swf from javascript, so this example in livedocs is what I'm trying to modify.

However,it is not working correctly for some reason. The problem I'm encountering is that it does not work in Safari and in Firefox, it only works if I put an alert in the function before javascript pass the value to swf. (seems like it needs some time) I also tried to set a timer in as3, but timer doesn't work, only alert in js helps.

All I wanted to do is use js to tell the swf file to play ep1.swf. Here's my js code:

document.observe('dom:loaded', function() {
    $('episode1').observe('click', function() {
        var params = {wmode : "transparent", allowScriptAccess:"always", movie:"header"};
        swfobject.embedSWF("swf/float.swf", "header", "100%", "100%", "9.0.0","expressInstall.swf", "", params, "");
function thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName];
    } else {
        return document[movieName];
function sendToActionScript(value) {     

Here's my as3 code:

private function receivedFromJavaScript(value:String):void {

    loader.load(new URLRequest(value));


I've been trying for a really long time, does anyone know how to fix this? Thanks.


The problem is that the SWF file isn't fully loaded by the time you try to call it. The flash player is probably loaded but it takes a while to load and initialise the swf file.

What you need to do is make a call from the SWF file to a javascript function when it's loaded and put your javascript there rather than in the page loaded handler that you seem to be doing now. That way you know that your flash application is properly initialized by then. The ExternalInterface class you are using has methods to let you call back into the javascript.

Need Your Help

On usage of <br> tag line-height does not work. Why?


On usage of break tag in a div the line-height property is not working with any of the attributes,

Split an NSArray in smaller key value coded arrays using a common key-value pair between objects

objective-c arrays sorting split

I'm trying to find a good solution to split an array of dictionaries in a smaller dictionaries keyed by a common value between them. Here is an example i JSON, I start from this: { "field": [...