最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Interacting with actionscript 3.0 using javascript - Stack Overflow

programmeradmin2浏览0评论

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 e 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. .do?externalId=tn_15683&sliceId=1

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

/

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!

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 e 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./selfservice/viewContent.do?externalId=tn_15683&sliceId=1

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

http://www.jesuscarrera.info/2009/01/05/munication-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!

Share Improve this question edited May 21, 2013 at 6:33 justnajm 4,5346 gold badges38 silver badges56 bronze badges asked Jan 20, 2009 at 5:56 user56963user56963 691 gold badge2 silver badges11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

The example you posted uses the ExternalInterface class to municate 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>
发布评论

评论列表(0)

  1. 暂无评论