Chapter 13 Example 2

by actionscriptbible
♥0 | Line 18 | Modified 2009-11-11 06:46:29 | 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/vtXg
 */

package {
  import com.actionscriptbible.Example;
  public class ch13ex2 extends Example {
    public function ch13ex2() {
      //a nice raspberry color, 0xD41153
      var r:uint = 0xD4;
      var g:uint = 0x11;
      var b:uint = 0x53;
      //of course we could just type in 0xD40253 to our code,
      //but what if the user input these values? We have to reassemble it.
      trace16(r << 16); //0xd40000
      trace16(g << 8);  //0x001100
      trace16(b);       //0x000053
      var rgb:uint = (r << 16) + (g << 8) + b;
      trace16(rgb); //0xd41153
    }
    public function trace16(n:uint):void {
      trace("0x" + n.toString(16));
    }
  }
}