Use variables or complex expressions to specify an element index
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var trees:Array = ["b", "m", "o", "c"];
var i = 3;
var lastTree:String = trees[i];
var randomTree:String = trees[Math.floor(Math.random( ) * 4)];
trace(lastTree);
trace(randomTree);
}
}
}
Related examples in the same category