If the container is hosting the Netscape plug-in, you can either write custom support for the
new NPRuntime interface or embed an HTML control and embed Flash Player within the
HTML control. If you embed an HTML control, you can communicate with Flash Player
through a JavaScript interface that talks to the native container application.
Availability: ActionScript 1.0; Flash Player 8
Parameters
methodName:String
accepts parameters, they must appear following the
parameter1:Object
specify zero or more parameters, separating them by commas. The parameters can be of any
ActionScript data type. When the call is to a JavaScript function, the ActionScript types are
automatically marshalled into JavaScript types. When the call is to some other ActiveX
container, the parameters are encoded in the request message.
Returns
- The response received from the container. If the call failed (for example if there is no
Object
such function in the container, or the interface was not available, or a recursion occurred, or
there was a security issue)
Example
The following example calls the JavaScript function
contains the SWF. The call is made by using the
import flash.external.*;
var greeting:String;
var btn:MovieClip = createButton(100, 30, 0xCCCCCC);
btn.onPress = function() {
greeting = String(ExternalInterface.call("sayHello", "browser"));
this.mcTxt.text = greeting; // >> Hi Flash.
}
function createButton(width:Number, height:Number, color:Number):MovieClip
{
var depth:Number = this.getNextHighestDepth();
var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth);
var mcFmt:TextFormat;
mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
554
ActionScript classes
- The name of the function to call in the container. If the function
[optional] - Any parameters to be passed to the function. You can
is returned.
null
parameter.
methodName
in the HTML page that
sayHello()
ExternalInterface.call()
method.
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?