Chapter 13 Example 1

by actionscriptbible
♥0 | Line 24 | Modified 2009-11-11 06:03:43 | 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/u63y
 */

package {
  import com.actionscriptbible.Example;
  public class ch13ex1 extends Example {
    public function ch13ex1() {
      var a:uint = 0x4;
      trace2(a);       //  100
      trace2(a >> 1);  //   10
      trace2(a << 1);  // 1000
      trace16(a << 8); //0x400  
      
      var b:uint = 0xb;
      trace2(b);       // 1011
      b >>= 2;
      trace2(b);       //   10
      b <<= 2;
      trace2(b);       // 1000
    }
    public function trace2(n:uint):void {
      trace(n.toString(2));
    }
    public function trace16(n:uint):void {
      trace("0x" + n.toString(16));
    }
  }
}