Listen for my Flash event in Javascript

懵懂的女人 提交于 2019-12-01 21:21:52

In the Model.as file find add this line in with all the other imports (at the start of the file):

import flash.external.*;

Then in the end event, add this line:

ExternalInterface.call("stopedPlaying");

So that an event would look like this:

        public function endOfItem():void {
            sendEvent(EVENT_END_OF_ITEM);
            // inform JavaScript that the FLV has stopped playing
            ExternalInterface.call("stoppedPlaying");
        }

Then in your the HTML document, add this between SCRIPT tags:

function stoppedPlaying()
{
    // do something when the FLV starts playing
};

I think that externalInterface plugin for jQuery will make it relatively easy. If not then there's DOMEx class which looks promising. Code example from DOMEx site:

if (ExternalInterface.available) ExternalInterface.call(javaScript, "Howdy Ya'll");
[...]

you can use SWF object project google
http://code.google.com/p/swfobject/

This library gives you the capability to listen events from actionscript to javascript and is very simple to use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!