EasyManua.ls Logo

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT - Page 371

MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT
816 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
delete 371
delete
Availability
Flash Player 5.
Usage
delete reference
Parameters
reference
The name of the variable or object to eliminate.
Returns
A Boolean value.
Description
Operator; destroys the object or variable specified by the reference parameter, and returns true
if the object was successfully deleted; otherwise returns a value of
false. This operator is useful
for freeing up memory used by scripts. Although
delete is an operator, it is typically used as a
statement, as in the following:
delete x;
The delete operator may fail and return false if the reference parameter does not exist, or
may not be deleted. Predefined objects and properties, and variables declared with
var, may not
be deleted. You cannot use the
delete operator to remove movie clips.
Example
Usage 1: The following example creates an object, uses it, and then deletes it after it is no longer
needed.
account = new Object();
account.name = 'Jon';
account.balance = 10000;
delete account;
Usage 2: The following example deletes a property of an object.
// create the new object "account"
account = new Object();
// assign property name to the account
account.name = 'Jon';
// delete the property
delete account.name;
Usage 3: The following is another example of deleting an object property.
// create an Array object with length 0
my_array = new Array();
// add an element to the array. Array.length is now 1
my_array[0] = "abc";
// add another element to the array. Array.length is now 2
my_array[1] = "def";
// add another element to the array. Array.length is now 3
my_array[2] = "ghi";
// my_array[2] is deleted, but Array.length is not changed

Table of Contents

Related product manuals