Skip to content Skip to sidebar Skip to footer

Passing Variable From Javascript To Flash

I have a flash music player that I would like to accept a parameter via a button click on a website. I'm thinking I could do this with javascript but not sure how. Does anybody ha

Solution 1:

You're going to utilize the flash.external.ExternalInterface class.

Adobe docs: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExternalInterface.html

A simple google search for "AS3 ExternalInterface example" will yield more than enough results to point you in the right direction.

Solution 2:

http://painteddigital.com/2008/calling-flash-as3-functions-from-javascript/

In the flash add a callback for the javascript function:

import flash.external.ExternalInterface;
ExternalInterface.addCallback("sendTextToFlash", getTextFromJavaScript);
function getTextFromJavaScript(str):void {
    trace(str);
}

In the html/js call it:

<scripttype="text/javascript">var currentPage="Home";
    functionsetCurrentPage(newPage) {
        currentPage = newPage;
        SendDataToFlashMovie(newPage);
    }

Calling JS Function From Flash: getURL("javascript:myfunction();");

Post a Comment for "Passing Variable From Javascript To Flash"