Chapter 6 Example 5

by actionscriptbible
♥0 | Line 14 | Modified 2010-01-20 17:52:53 | 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/uFwt
 */

package {
  import com.actionscriptbible.Example;
  public class ch6ex5 extends Example {
    public function ch6ex5() {
      var address:String = "Fourscore and seven years ago...";
      var firstSpace:int = address.indexOf(" ");
      var firstWord:String = address.slice(0, firstSpace);
      trace(firstWord); //Fourscore
      var ellipsis:String = address.slice(-3); //takes the last 3 characters.
      trace(ellipsis); //...
      trace(address.substr(4, 5)); //score     
    }
  }
}

Forked