03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Parameters<br />

methodName:String - The name by which the <strong>ActionScript</strong> function can be called from<br />

JavaScript. This name does not need to match the actual name of the <strong>ActionScript</strong> method.<br />

instance:Object - The object to which this resolves in the method. This object is not<br />

necessarily the object on which the method can be found — you can specify any object (or<br />

null).<br />

method:Function - The <strong>ActionScript</strong> method to be called from JavaScript.<br />

Returns<br />

Boolean - If the call succeeded, returns true. If it failed because the instance was not<br />

available, a security restriction was encountered, there was no such function object, a<br />

recursion occurred, or something similar, returns false.<br />

A return value of false may also mean that the containing environment belongs to a security<br />

s<strong>and</strong>box to which the calling code does not have access. You can work around this problem by<br />

doing the following:<br />

■ In the tag for the SWF file in the containing HTML page, set the following<br />

parameter:<br />

<br />

■ In the SWF file, add the following <strong>ActionScript</strong>:<br />

System.security.allowDomain(sourceDomain)<br />

Example<br />

The following example registers the goTo<strong>Adobe</strong>() function as callable from the container<br />

with the name goHome.<br />

import flash.external.*;<br />

var methodName:String = "goHome";<br />

var instance:Object = null;<br />

var method:Function = goTo<strong>Adobe</strong>;<br />

var wasSuccessful:Boolean = ExternalInterface.addCallback(methodName,<br />

instance, method);<br />

var txtField:TextField = this.createTextField("txtField",<br />

this.getNextHighestDepth(), 0, 0, 200, 50);<br />

txtField.border = true;<br />

txtField.text = wasSuccessful.toString();<br />

ExternalInterface (flash.external.ExternalInterface) 559

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!