0

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 have any sample code for both the javascript and what I would use to request the variable inside my actionscript code?

Thanks, I appreciate it!

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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:

<script type="text/javascript">
    var currentPage="Home";
    function setCurrentPage(newPage) {
        currentPage = newPage;
        SendDataToFlashMovie(newPage);
    }

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

2 Comments

I'm having a hard time getting that guys code to work. I have FlashBug running and I'm looking for a trace. Nothing is happening. What's supposed to happen when you click the home button?
Here is my dev page if you're interested in looking: rt.jaxna.com/index.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.