开发者

How to interact with Flash via Javascript?

At this moment there is a very basic flash project that connects to a rtmp server and streams v开发者_开发问答ideo&audio from webcam. It creates a stream from a user with a certain name.

Also in same project there is an input for a stream name that other entity can stream. Therefore you get Skype alike video-chat with flash.

In flash I can control when I want to start publishing own stream and when want to play someone else's stream.

I am trying to figure out how I can control Flash Functions (StartPublish, StartStream, etc) via Javascript.

I am looking at http://osflash.org/projects/flashjs and would like to know if I am on right path.


http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html

The ExternalInterface class is designed specifically for this purpose. It's a relatively simple class for exposing actionscript functions to JS or vice versa. I recently implemented it in an audio player my team developed to have an HTML formatted tracklist trigger play and stop events.

Essentially, you can make your code first check against ExternalInterface.available to make sure the container has an external interface (IE in a browser window with javascript and not just running from flash player.) From there, you can use addCallback to designate a function that can then be called on the flash applet's container.

You can then call it using the typical javascript - just access the method off of the container using getElementByID or whatever selector flavor you prefer if you're using a framework.

Make sure your embed method allows script access to the flash applet as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜