1

As the title says... I'm trying to interact with my flash movie's actionscript via javascript. Specifically I'm trying to send text to my flash movie. I've come across a couple sites that had some walkthroughs but I for the life of me could not get them to work.

From the adobe site. http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15683&sliceId=1

the really cool thing about that is their source file download link is dead. and coming across another post:

http://www.jesuscarrera.info/2009/01/05/communication-between-actionscript-3-and-javascript/

The download works... except the fla file is blank and running the html page you can receive text from the flash movie... but you can't send text from html to the flash movie.

I followed the steps pretty closely, can anybody see anything wrong w/ the instructions on the adobe site? And if ANYBODY can reeeeeally help me out, could you post a source example of this functionality? Thanks everybody for your time!

1 Answer 1

2

The example you posted uses the ExternalInterface class to communicate from Flash to Javascript. You can add callbacks using the ExternalInterface but if you need to trigger a function from the DOM (HTML) that goes to FLASH.

OK, now to get values from Javascript to Flash there are a few options.
You can set up a callback function using the ExternalInterface Class. Here is an example from Live Docs link text

If you need to call the Flash from Javascript without ANY Flash interaction (like to play a video or something), again you will use the ExternalInterface. Here is an AS3 example link text

Here is an AS2 example to answer your question:

//AS2
import flash.external.*;
function helloWorld():Void
{
    //Do something
}
ExternalInterface.addCallback("myFunction", helloWorld);

// HTML
<script language="JavaScript">

    flashObject.myFunction();
</ script>
...
<object id="flashObject"...>
    ...
    <embed name="flashObject".../>
</object>
Sign up to request clarification or add additional context in comments.

Comments

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.