Chapter 10 Example 1

by actionscriptbible
♥0 | Line 14 | Modified 2009-06-09 02:35:44 | 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/hRo2
 */

package  {
  import com.actionscriptbible.Example;
  public class ch10ex1 extends Example {
    public function ch10ex1() {
      var shape:Object = new Object();
      shape.name = "hexagon";
      shape.sides = 6;
      shape["color"] = 0x00ff00;
      shape["stroke weight"] = 2;
      shape["describe"] = function():String {return "A " + this.name;};
      trace(shape.describe() + " has " + shape.sides + " sides.");
      // Displays: A hexagon has 6 sides.
    }
  }
}