Name
ExternalInterface.addCallback( ): expose an ActionScript method for execution from JavaScript â ActionScript function in Flash 8
Synopsis
boolean ExternalInterface.addCallback(Stringname
, Objectinstance
, Functionfunc
)
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 theinstance
object.-
instance
The ActionScript object on which
func
is to be invoked ornull
. This argument becomes the value of thethis
keyword whenfunc
is invoked.-
func
The ActionScript function that is invoked when the JavaScript function named
name
is invoked.
Returns
true
on success or
false
on failure.
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 ...
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.