03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - 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.

Example<br />

The following example defines the function sqr, which accepts one parameter <strong>and</strong> returns the<br />

Math.pow(x, 2) of the parameter:<br />

function sqr(x:Number) {<br />

return Math.pow(x, 2);<br />

}<br />

var y:Number = sqr(3);<br />

trace(y); // output: 9<br />

If the function is defined <strong>and</strong> used in the same script, the function definition may appear<br />

after using the function:<br />

var y:Number = sqr(3);<br />

trace(y); // output: 9<br />

function sqr(x:Number) {<br />

return Math.pow(x, 2);<br />

}<br />

The following function creates a LoadVars object <strong>and</strong> loads params.txt into the SWF file.<br />

When the file successfully loads, variables loaded traces:<br />

var myLV:LoadVars = new LoadVars();<br />

myLV.load("params.txt");<br />

myLV.onLoad = function(success:Boolean) {<br />

trace("variables loaded");<br />

}<br />

get statement<br />

function get property () { // your statements here }<br />

Note: To use this keyword, you must specify ActionScript 2.0 <strong>and</strong> Flash Player 6 or later in<br />

the Flash tab of your FLA file's Publish Settings dialog box. This keyword is supported only<br />

when used in external script files, not in scripts written in the Actions panel.<br />

Permits implicit getting of properties associated with objects based on classes you have defined<br />

in external class files. Using implicit get methods lets you access properties of objects without<br />

accessing the property directly. Implicit get/set methods are syntactic shorth<strong>and</strong> for the<br />

Object.addProperty() method in ActionScript 1.<br />

Parameters<br />

property:String - The word you use to refer to the property that get accesses; this value<br />

must be the same as the value used in the corresponding set comm<strong>and</strong>.<br />

Statements 185

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

Saved successfully!

Ooh no, something went wrong!