views:

283

answers:

2

Im testing a program in FlashDevelop, which uses Flash player 10. Need externalInterface to work, but on running this simple test program, it displays "ExternalInterface is not available". What might be the problem here? How do I get ExternalInterface working?

http://blog.flexexamples.com/2008/03/10/checking-to-see-if-the-externalinterface-api-is-available-in-flex/ -->

<mx:Script>
    <![CDATA[
        import mx.controls.Alert;

        private function init():void {
            if (ExternalInterface.available) {
                ExternalInterface.call("alert",
                        "ExternalInterface is available");
            } else {
                Alert.show("ExternalInterface is not available");
            }
        }
    ]]>
</mx:Script>

<mx:ApplicationControlBar dock="true">
    <mx:Button id="button"
            label="ExternalInterface.available"
            click="init();" />
</mx:ApplicationControlBar>

P.s - By the way, this script shows "External Interface is available" when I run it in my browser. Its only when I run it in Flash Player 10, that it is not available.

A: 

Have a look at the ExternalInterface example in the flash as3 docs. There is an html setup as well.

Basically you need to make sure you use the same string for the embed name is the same as for the object id, the html tags, as you can see in your example from flexamples.

Have a look at the html source on that site.

George Profenza
ExternalInterface is working on my browser, its only in Flash Player 10 that it is not working.
Pranav
You can only test ExternalInterface in the browser. As vitch mentioned, ExternalInterfaces bridges your swf with javascript within an html page. No HTML = nothing to bridge = no ExternalInterface.
George Profenza
+2  A: 

ExternalInterface doesn't exist in the Standalone player:

http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00000339.html

In all other situations (such as running in a stand-alone player), the ExternalInterface.available property returns false.

It is for communicating with the thing which contains the flash player and when running in the standalone player there is nothing containing it so there is nothing to communicate with.

vitch