You need to have a look at the documentation for ExternalInterface, which provides the link between JavaScript and Flash in a webpage.
The basics run along the lines of importing the library in Flash:
import flash.external.ExternalInterface;
Then you can bind a routine to be called from Javascript by using addCallback()
:
ExternalInterface.addCallback('stopVideo', stopVideo);
function stopVideo() {
...
}
That provides a function called stopVideo()
on the flash object on the webpage.
And you can call a Javascript function from Flash by using call()
:
ExternalInterface.call('updatePlayerInfo', "STOPPED");
That calls a Javascript routine called updatePlayerInfo()
with the argument 'STOPPED'
.
The AS3 documentation for ExternalInterface is much the same as AS2, I can not seem to locate the AS2 documentation at present.