Section 25.115. ExternalInterface.addCallback( ): expose an ActionScript method for execution from JavaScript


25.115. ExternalInterface.addCallback( ): expose an ActionScript method for execution from JavaScript

ActionScript function in Flash 8

25.115.1. Synopsis

 boolean ExternalInterface.addCallback(String name,                                       Object instance,                                       Function func) 

25.115.1.1. Arguments

name

The name of the JavaScript function to be defined. Invoking a JavaScript function with this name causes the Flash player to invoke the ActionScript function func as a method of the instance object.


instance

The ActionScript object on which func is to be invoked or null. This argument becomes the value of the this keyword when func is invoked.


func

The ActionScript function that is invoked when the JavaScript function named name is invoked.

25.115.1.2. Returns

TRue on success or false on failure.

25.115.2. Description

This static function is used by ActionScript code in a Flash movie to enable JavaScript code in a web browser to invoke ActionScript code. When addCallback( ) is invoked, it defines a top-level JavaScript function called name which, when invoked, calls the ActionScript function func as a method of the ActionScript object instance.

The arguments to the JavaScript function are converted and passed to func, and the return value of func is converted and becomes the return value of the JavaScript function. Arguments and return values can be primitive numbers, strings, boolean values, and objects and arrays that contain primitive values. However, it is not possible, for example, to pass a client-side JavaScript object such as a Window or Document to an ActionScript function. It is also not possible to return a Flash-specific ActionScript object such as a MovieClip to JavaScript.

25.115.3. See Also

FlashPlayer; Chapter 23




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net