Chapter 8 Example 1
♥0 |
Line 18 |
Modified 2009-06-12 01:23:41 |
MIT License
archived:2017-03-09 18:42:44
ActionScript3 source code
/**
* Copyright actionscriptbible ( http://wonderfl.net/user/actionscriptbible )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/lNss
*/
package {
import com.actionscriptbible.Example;
public class ch8ex1 extends Example {
public function ch8ex1() {
//array literals
var fibonacci:Array = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
var a:Array = [];
var b:Array = [1, 2, 3,]; //trailing comma ok
//looking up a value by index
var animals:Array = ["newt", "vole", "cobra", "tortoise"];
trace(animals[2]); //cobra
//assigning a value by index
animals[0] = "salamander";
trace(animals); //salamander,vole,cobra,tortoise
//finding the length
var veggies:Array = new Array();
trace(veggies.length); //0
veggies = ["corn", "bok choy", "kale", "beet"];
trace(veggies.length); //4
}
}
}