第一种最简单的方法是:
var arr:Array = ["a", "b", "c", "d", "e", "f"];
arr=[];

第二种:pop()删除数组中最后一个元素,并返回该元素的值。
arr:Array = ["a", "b", "c", "d", "e", "f"];
for (var i:Number = arr.length-1; i>=0; i--) {
_arr.pop();
}

第三种:splice()给数组添加元素以及从数组中删除元素
var arr:Array = ["a", "b", "c", "d", "e", "f"];
for (var i:Number = arr.length-1; i>=0; i--) {
arr.splice(i);
}
使用 startIndex 参数的元素索引 1 连接该数组。这将删除数组中从第二个元素开始的所有元素,只保留原始数组中索引 0 处的元素:

var arr:Array = new Array("a", "b", "c", "d");
trace( myPets_array.splice(1) );

trace( myPets_array );

第四种:有时候我们需要将某个数组清空或者说重置,我最常用的办法的是重新new一下,
但是有人测试研究发现使用length=0的方法,执行效率是最高的,呵呵,原文如下:

_localArray.length = 0; // Reset the array to empty

AS3清空数组的四种方法的更多相关文章

  1. JS 中检测数组的四种方法

    今天和大家分享一下 JS 中检测是不是数组的四种方法,虽然篇幅不长,不过方法应该算是比较全面了. 1. instanceof 方法 instanceof 用于检测一个对象是不是某个类的实例,数组也是一 ...

  2. ZH奶酪:JavaScript清空数组的三种方法

    参考链接:http://snandy.iteye.com/blog/893955 方式1,length赋值为0 目前 Prototype中数组的 clear 方法和mootools库中数组的 empt ...

  3. JavaScript清空数组的三种方法

    [文章系摘自网络,看到有用记录在博客,同时共享给大家] 原链接:http://www.2cto.com/kf/201409/335383.html 方式1,splice   var ary = [1, ...

  4. JS004. 获取数组最后一个元素且不改变数组的四种方法

    TAG: Array.length Array.prototype.reverse() Array.prototype.slice() Array.prototype.pop() Array对象 - ...

  5. C++遍历二维数组的四种方法

    #include <iostream> using std::cin; using std::cout; using std::endl; using std::string; using ...

  6. python 清空list的几种方法

    本文介绍清空list的四种方法,以及 list=[ ] 和 list.clear() 在使用中的区别(坑). 1.使用clear()方法 lists = [1, 2, 1, 1, 5] lists.c ...

  7. 【AS3】Flash与后台数据交换四种方法整理

    随着Flash Player 9的普及,AS3编程也越来越多了,所以这次重新整理AS3下几种与后台数据交换方法.1.URLLoader(URLStream)2.FlashRemoting3.XMLSo ...

  8. JS去除数组中重复值的四种方法

    JS去除数组中重复值的四种方法 1 /// <summary>            o[this[i]] = "";  }      }       newArr.p ...

  9. JAVA中运用数组的四种排序方法

    JAVA中在运用数组进行排序功能时,一般有四种方法:快速排序法.冒泡法.选择排序法.插入排序法. 快速排序法主要是运用了Arrays中的一个方法Arrays.sort()实现. 冒泡法是运用遍历数组进 ...

随机推荐

  1. Find the k-th Smallest Element in the Union of Two Sorted Arrays

    (http://leetcode.com/2011/01/find-k-th-smallest-element-in-union-of.html) Given two sorted arrays A, ...

  2. C++ 字符串分割,分割到vector中

    #include <string> #include <vector> using std::string; using std::vector; int splitStrin ...

  3. php 图片等比缩放

    /** * @method 图片等比缩放 * @param string $srcImage 源图片路径 * @param string $toFile 目标图片路径 * @param integer ...

  4. ThinkPHP常量参考

    常用常量 APP_NAME 当前项目名称 APP_PATH 当前项目路径 GROUP_NAME 当前分组名称 MODULE_NAME 当前Action模块名称 ACTION_NAME 当前操作的名称 ...

  5. php如何开启GD库

    GD库是干什么用的呢!它是php处理图形的扩展库,GD库提供了一系列用来处理图片的API,使用GD库可以处理图片,或者生成图片.GD库在php中默认是没有开启的,如果想让它支持图片处理功能,那么就要手 ...

  6. PHP学习(变量)

    PHP学习(变量) 1. PHP属于松散类型,创建变量时不用指定类型. 2.变量命名规范: 1)第一个字符必须是$ 2)$后的第一个字符必须是 字母 或 下划线 3)其他字符可以是 字母, 数字, 下 ...

  7. 6.PHP 教程_PHP数据类型

    PHP数据类型 String(字符串),Integer(整型),Float(浮点型),Boolean(布尔型),Array(数组),Object(对象), NULL(空值). PHP字符串 一个字符串 ...

  8. [LeetCode]题解(python):002-Add Two Numbers

    题目来源: https://leetcode.com/problems/add-two-numbers/ 题意分析: 这道题目是要将两个单链条相加.输出得到的新链条. 题目思路: 不难发现,其实题目就 ...

  9. nginx启动、开机自启动、重启、关闭

    yum -y  install nginx # yum info nginx Loaded plugins: fastestmirror Loading mirror speeds from cach ...

  10. centos 环境下monolog+php 方案

    1.在项目中,日志系统有多重要详细所有程序员都知道,monolog就是一个最好的解决方案,有各种级别,各种日志存储方式,具体可以上monolog官方了解http://monolog.ow2.org/ ...