ExternalInterface

Posted by Jesse on Stack Overflow See other posts from Stack Overflow or by Jesse
Published on 2010-04-29T09:41:06Z Indexed on 2010/04/29 16:17 UTC
Read the original article Hit count: 376

Hey, so I'm having a bunch of trouble getting ExternalInterface to work, which is odd, because I use it somewhat often.

I'm hoping it's something I just missed because I've been looking at it too long.

The flash_ready function is correctly returning the objectID, and as far as I can tell, everything else is in order.

Unfortunately, when I run it, I get an error (varying by browser) telling me that basically document.getElementById(<movename>).test() is not a valid method.

Here's the code:

javascript:

function flash_ready(i){
    document.getElementById(i).test('success!'); 
}

Embed Html (Generated):

<script type="text/javascript">
    swfobject.embedSWF("/chainmaille/includes/media/flash/upload_image.swf", "/chainmaille/includes/media/flash/upload_image", "500", "50", "9.0.0","expressInstall.swf", {}, {allowScriptAccess:'always', wmode:'transparent'},{id:'uploader_flash',name:'uploader_flash'});
</script>
<object type="application/x-shockwave-flash" id="uploader_flash" name="uploader_flash" data="/chainmaille/includes/media/flash/upload_image.swf" width="500" height="50"><param name="allowScriptAccess" value="always"><param name="wmode" value="transparent"></object>

AS3 :

package com.jesseditson.uploader {

  import flash.display.MovieClip;
  import flash.external.ExternalInterface;
  import flash.system.Security;

    public class UI extends MovieClip {

     // Initialization:
     public function UI() {
        Security.allowDomain('*');
        ExternalInterface.addCallback("test", test);

        var jscommand:String = "flash_ready('"+ExternalInterface.objectID+"');";
        var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");
        navigateToURL(url, "_self");
    }

    public function test(t){
      trace(t);
    }
  }
}

Swfobject is being included via google code, and the flash embeds just fine, so that's not the problem.

I've got a very similar setup working on another server, but can't seem to get it working on this one. It's a Hostgator shared server. Could it be the server's fault? Anybody see any obvious syntax problems?

Thanks in advance!

© Stack Overflow or respective owner

Related posts about externalinterface

Related posts about actionscript-3