Question :How do you call javascript from Flex?
Answer :The ExternalInterface class is the External API, an application programming interface that enables
straightforward communication between ActionScript and the Flash Player container– for example,
an HTML page with JavaScript. Adobe recommends using ExternalInterface for all JavaScript-
ActionScript communication.
You can call an ActionScript function in Flash Player, using JavaScript in the HTML page. The
ActionScript function can return a value, and JavaScript receives it immediately as the return value
of the call.
This functionality replaces the fscommand() method.
The ExternalInterface class requires the user's web browser to support either ActiveX® or the
NPRuntime API that is exposed by some browsers for plug-in scripting. Even if a browser and
operating system combination are not listed above, they should support the ExternalInterface class if
they support the NPRuntime API. See http://www.mozilla.org/projects/plugins/npruntime.html.
Note: When embedding SWF files within an HTML page, make sure that the id and name attributes
of the object and embed tags do not include the following characters: . - + * / \
From ActionScript, you can do the following on the HTML page:
•Call any JavaScript function.
•Pass any number of arguments, with any names.
•Pass various data types (Boolean, Number, String, and so on).
•Receive a return value from the JavaScript function.
From JavaScript on the HTML page, you can:
•Call an ActionScript function.
•Pass arguments using standard function call notation.
•Return a value to the JavaScript function.
Flash Player does not currently support SWF files embedded within HTML forms.
No comments:
Post a Comment