Show
Ignore:
Timestamp:
12/19/07 04:35:09 (13 months ago)
Author:
gyuque
Message:

lang/legacy-actionscript/as2draw: added color button

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/legacy-actionscript/as2draw/AS2Draw.as

    r3301 r3302  
    44        private var mToolPalette:ToolPalette; 
    55        private var mSelectedPenButton:PenButton; 
     6        private var mSelectedColorButton:ColorButton; 
     7        public var DEFAULT_COLORS:Array = [0xffffff, 0xdddddd, 0x888888, 0x000000, 0xf04433, 0xffaf98, 0x80c090]; 
    68 
    79        public function AS2Draw(aRoot:MovieClip) 
    810        { 
    9                 mToolPalette = new ToolPalette(aRoot, 480, 24, 0x888888); 
     11                mToolPalette = new ToolPalette(aRoot, 480, 56, 0x888888); 
    1012                buildToolPalette(mToolPalette); 
    1113 
    12                 mDrawable    = new Drawable   (aRoot, 0xeeffdd, 480, 200); 
    13                 mDrawable.setY(24); 
     14                mDrawable    = new Drawable   (aRoot, 0xffffff, 480, 232); 
     15                mDrawable.setY(56); 
    1416        } 
    1517         
     
    1719        { 
    1820                var _this = this; 
    19                 var closure = function(b){_this.pushedPenButton(b);}; 
    2021                 
    21                 var p1:PenButton = new PenButton(3); 
    22                 tp.addButton(p1); 
    23                 p1.afterPush = closure; 
     22                { 
     23                        var closure = function(b){_this.pushedPenButton(b);}; 
     24                         
     25                        var p1:PenButton = new PenButton(3); 
     26                        tp.addButton(p1); 
     27                        p1.afterPush = closure; 
    2428 
    25                 var p2:PenButton = new PenButton(8); 
    26                 tp.addButton(p2); 
    27                 p2.afterPush = closure; 
     29                        var p2:PenButton = new PenButton(8); 
     30                        tp.addButton(p2); 
     31                        p2.afterPush = closure; 
    2832 
    29                 var p3:PenButton = new PenButton(16); 
    30                 tp.addButton(p3); 
    31                 p3.afterPush = closure; 
     33                        var p3:PenButton = new PenButton(16); 
     34                        tp.addButton(p3); 
     35                        p3.afterPush = closure; 
     36                         
     37                        pushedPenButton(p1); 
     38                } 
     39                 
     40                tp.appendBlank(8); 
     41                 
     42                { 
     43                        var l = DEFAULT_COLORS.length; 
     44                        var closure = function(b){_this.pushedColorButton(b);}; 
     45                        for (var i:Number = 0;i < l;i++) 
     46                        { 
     47                                var cb:ColorButton = new ColorButton(DEFAULT_COLORS[i]); 
     48                                tp.addButton(cb); 
     49 
     50                                cb.afterPush = closure; 
     51                        } 
     52                } 
    3253        } 
    3354         
     
    4364        } 
    4465 
     66        private function pushedColorButton(aButton:ColorButton) 
     67        { 
     68                if (mSelectedColorButton) 
     69                { 
     70                        mSelectedColorButton.setSelected(false); 
     71                } 
     72                 
     73                mSelectedColorButton = aButton; 
     74                mSelectedColorButton.setSelected(true); 
     75        } 
     76         
    4577        static function main() 
    4678        {