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
Содержание FLASH MX 2004 - ACTIONSCRIPT
Страница 1: ...ActionScript Reference Guide...
Страница 8: ...8 Contents...
Страница 12: ......
Страница 24: ...24 Chapter 1 What s New in Flash MX 2004 ActionScript...
Страница 54: ...54 Chapter 2 ActionScript Basics...
Страница 80: ...80 Chapter 3 Writing and Debugging Scripts...
Страница 82: ......
Страница 110: ...110 Chapter 5 Creating Interaction with ActionScript...
Страница 112: ......
Страница 120: ...120 Chapter 6 Using the Built In Classes...
Страница 176: ......
Страница 192: ...192 Chapter 10 Working with External Data...
Страница 202: ...202 Chapter 11 Working with External Media...
Страница 204: ......
Страница 782: ...782 Chapter 12 ActionScript Dictionary...
Страница 793: ...Other keys 793 221 222 Key Key code...
Страница 794: ...794 Appendix C Keyboard Keys and Key Code Values...
Страница 798: ...798 Appendix D Writing Scripts for Earlier Versions of Flash Player...
Страница 806: ...806 Appendix E Object Oriented Programming with ActionScript 1...
Страница 816: ...816 Index...