views:

2533

answers:

3

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!

+2  A: 

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>
discorax
+3  A: 

a little more searching yielded:

http://blog.circlecube.com/2008/02/01/actionscript-javascript-communication/

:) hope this helps someone else.

+1  A: 

Had to do some work on this recently and found that this article helped a lot:

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15683

Karthik