Search code examples
javascriptflashplayback

How can I start a flash video from javascript?


Is it possible to start playing a file inside a flash player by making use of javascript code? If so, how would I do it?


Solution

  • Try using swfObject, you can make any actionscript function visible for javascript using ExternalInterface and declaring them into javascript. So you can trigger actionscript function with play() (or any other code you want) from your javascript code.

    Here is an example:

    Actionscript:

    import flash.external.ExternalInterface;
    
    ExternalInterface.addCallback( "methodName", this, method );
    function method() {
       trace("called from javascript");
    }
    

    Javascript:

    function callAS() {
       swf.methodName(); 
    }
    

    Where methodName is the identifier js uses to call the method from actionscript.