Use variables or complex expressions to specify an element index : Array Index : Array Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Array » Array Index »

 

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);
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Array
» Array Index