Chapter 8 Example 4

by actionscriptbible
♥0 | Line 16 | Modified 2009-06-12 03:33:16 | MIT License
play

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/meuh
 */

package {
  import com.actionscriptbible.Example;
  public class ch8ex4 extends Example {
    public function ch8ex4() {
      var nobleGasses:Array = ["helium", "neon", "argon", "pentagon", "xenon", "radon"];
      var shapes:Array = nobleGasses.splice(3, 1, "krypton");
      //delete 1 element at index 3, and replace it with "krypton".
      trace(nobleGasses); //helium,neon,argon,krypton,xenon,radon
      trace(shapes); //pentagon
      
      var metals:Array = ["iron", "copper", "gold", "silver", "platinum", "tin", "chrome"];
      var preciousMetals:Array = metals.slice(2,5);
      trace(preciousMetals); //gold,silver,platinum
      var canMakingMetal:Array = metals.slice(-2,-1);
      trace(canMakingMetal); //tin
    }
  }
}

Forked