http://arrixlive.wordpress.com/2005/03/25/javascript-in-love-with-flash-control-swf-from-javascript/
Control the play back
If your swf is mainly a sequence of frames without complex programmatic logic, it is a good idea to control the playback from JavaScript. The following_Flash Methods _are intended for playback control.
1 | /* start playing the _root timeline */ |
Notice that the frameNumber starts at 0, unlike in Flash where the_ frame_number begins at 1. Before calling this method, you should ensure that the target frame has already been loaded.
1 | if (flashObj.PercentLoaded() == 100) { |
Calling a function defined in the Flash movie
There is no direct way to call a method defined in Flash from JavaScript_because JavaScript and ActionScript functions and types are not compatible. But there are various ways to trigger code execution in a Flash movie from_JavaScript.
You can place your ActionScript code in a particular frame (latterly referred to as Frame Function). Then in JavaScript:
1 | flashObj.GotoFrame(frameNumber); |
These functions control Flash movie playback. Jumping to the specified _frame_will of course trigger the code execution there.
The following two functions execute ActionScript code at specified _frame_without moving the play head.
1 | flashObj.TCallFrame("target", frameNumber); |