MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference page 232

Actionscript 2.0 language reference
Table of Contents

Advertisement

myFunction = function () {
trace("this is myFunction");
};
try {
myInterval = setInterval(this, "myFunction", 1000);
throw new Error("my error");
}
catch (myError:Error) {
trace("error caught: "+myError);
}
finally {
clearInterval(myInterval);
trace("error is cleared");
}
In the following example, the
regardless of whether or not an error occurred. Create a new AS file called Account.as:
class Account {
var balance:Number = 1000;
function getAccountInfo():Number {
return (Math.round(Math.random() * 10) % 2);
}
}
In the same directory as Account.as, create a new AS or FLA document and enter the
following ActionScript in Frame 1 of the Timeline:
import Account;
var account:Account = new Account();
try {
var returnVal = account.getAccountInfo();
if (returnVal != 0) {
throw new Error("Error getting account information.");
}
}
finally {
if (account != null) {
delete account;
}
}
The following example demonstrates a
executed. If an exception is thrown by any code in the
block, which shows the error message in a text field by using the
In the same directory as Account.as, create a new FLA document and enter the following
ActionScript in Frame 1 of the Timeline:
import Account;
var account:Account = new Account();
try {
232
ActionScript language elements
block is used to delete an ActionScript object,
finally
try..catch
statement. The code in the
block, control passes to the
try
Error.toString()
block is
try
catch
method.

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF