简体   繁体   中英

Flash/AS3: ExternalInterface.call() “Why u no console.log?”

I'm trying to do a very simple test to get the AS3 ExternalInterface.call() to Javascript console.log() for me.

I have a simple SWF with AS3 on a top layer and a button that triggers the call.

import flash.external.ExternalInterface;

function log(message:String):void
{
    trace (message);
    if (ExternalInterface.available)
    {
        ExternalInterface.call('console.log', message);
    }
}

button.addEventListener(MouseEvent.CLICK,button_click);

function button_click(e:MouseEvent):void
{
    log("Hello World");
}

I have tested this in the Flash IDE to make sure the button click is tracing and it is. I've been testing this in both the latest Chrome and Firefox browser.

Am I doing something fundamentally wrong?

tried the same. works for me. Make sure your addEventListener code inside a function like creation complete. it should be.

Also look at http://code.google.com/p/flash-thunderbolt/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM