Use variable as the array index
package{
import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var cities:Array = ["Toronto", "Montreal", "Vancouver", "Waterloo"];
var i:int = 1;
cities[i] = "Beijing";
trace(cities); //Toronto,Beijing,Vancouver,Waterloo
}
}
}
Related examples in the same category