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.

throw new RecordSetException();<br />

}<br />

else if (returnVal == 2) {<br />

throw new MalformedRecord();<br />

}<br />

}<br />

function r<strong>and</strong>omNum():Number {<br />

return Math.round(Math.r<strong>and</strong>om() * 10) % 3;<br />

}<br />

}<br />

Finally, in another AS file or FLA script, the following code invokes the sortRows() method<br />

on an instance of the RecordSet class. It defines catch blocks for each type of error that is<br />

thrown by sortRows()<br />

import RecordSet;<br />

var myRecordSet:RecordSet = new RecordSet();<br />

try {<br />

myRecordSet.sortRows();<br />

trace("everything is fine");<br />

}<br />

catch (e:RecordSetException) {<br />

trace(e.toString());<br />

}<br />

catch (e:MalformedRecord) {<br />

trace(e.toString());<br />

}<br />

See also<br />

Error<br />

var statement<br />

var variableName [= value1][...,variableNameN[=valueN]]<br />

Used to declare local variables. If you declare variables inside a function, the variables are local.<br />

They are defined for the function <strong>and</strong> expire at the end of the function call. More specifically,<br />

a variable defined using var is local to the code block containing it. Code blocks are<br />

demarcated by curly braces ({}).<br />

If you declare variables outside a function, the variables are available througout the timeline<br />

containing the statement.<br />

You cannot declare a variable scoped to another object as a local variable.<br />

my_array.length = 25; // ok<br />

var my_array.length = 25; // syntax error<br />

When you use var, you can strictly type the variable.<br />

Statements 205

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

Saved successfully!

Ooh no, something went wrong!