I\'m trying to edit some flash to make an external javascript function call, but with no success. Here\'s my actionscript 2.0 code:
//testing external .js ca
ExternalInterface.addCallback is for javascript to be able to call into your Flash application. If for example you want a HTML button that starts/stops a video you just add a callback for a named method and your js can than call [FlashObject].callback method name.
I would say that the best way to add ExternalInterface methods in your application is to set up a class responsible for JS communication for each interaction case in the app. For example:
public class ExternalVideoControl {
private var video:MediaDisplay;
public function ExternalVideoControl(video:MediaDisplay) {
//ExternalInterface.addCallback - one callback for each method you want to expose, pointing to a method within this class;
//add listeners on the video player and point them to methods in this class, for example onProgress
}
public function playVideo():void {
//play the video on the mediaDisplay
}
private function onProgress(event:ProgressEvent):void {
//ExternalInterface.call - report progress back to javascript
}
}
To test ExternalInterface more directly, try calling
ExternalInterface.call("alert", "Hello World!");