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

lang/legacy-actionscript/as2draw: added color button

Location:
lang/legacy-actionscript/as2draw
Files:
1 added
7 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        { 
  • lang/legacy-actionscript/as2draw/PenButton.as

    r3301 r3302  
    33        private var mWidth:Number; 
    44        private var mMC:MovieClip; 
    5         private var buttonWidth:Number  = 28; 
    6         private var buttonHeight:Number = 23; 
     5        private var buttonWidth:Number  = 40; 
     6        private var buttonHeight:Number = 55; 
    77        private var mSelectionColor:Number = 0xddeeff; 
    88        private var mDefaultColor:Number = 0xffffff; 
     
    2525                mMC = aParent.createEmptyMovieClip("pen-button-w"+mWidth, aIndex); 
    2626                drawSymbol(mMC, mSelected); 
    27                 mMC.useHandCursor = false; 
     27                mMC.useHandCursor = true; 
    2828                 
    2929                var _this = this; 
     
    4949                var cy:Number = buttonHeight/2; 
    5050         
    51                 mMC.clear(); 
     51                g.clear(); 
    5252                 
    53                 mMC.beginFill(selected ? mSelectionColor : mDefaultColor); 
    54                 U.rect(mMC, 0, 0, buttonWidth, buttonHeight); 
    55                 mMC.endFill(); 
     53                g.beginFill(selected ? mSelectionColor : mDefaultColor); 
     54                U.rect(g, 0, 0, buttonWidth, buttonHeight); 
     55                g.endFill(); 
    5656                 
    57                 g.lineStyle(mWidth, 0x000000); 
     57                g.lineStyle(mWidth, 0x000000, selected ? 100 : 60); 
    5858                g.moveTo(cx,    cy); 
    5959                g.lineTo(cx+0.5,cy); 
  • lang/legacy-actionscript/as2draw/ToolPalette.as

    r3276 r3302  
    3131        } 
    3232         
     33        public function appendBlank(aLeft:Number, aRight:Number) 
     34        { 
     35                if (aLeft) 
     36                        mNextLeft += aLeft; 
     37 
     38                if (aRight) 
     39                        mNextRight -= aRight; 
     40        } 
     41         
    3342        public function addButton(aBtn) 
    3443        { 
  • lang/legacy-actionscript/as2draw/U.as

    r3300 r3302  
    11class U /*Utility*/ 
    22{ 
    3         public static function rect(g:MovieClip, x:Number, y:Number, w:Number, h:Number) 
     3        public static function rect(g:MovieClip, x:Number, y:Number, w:Number, h:Number, close) 
    44        { 
    55                g.moveTo(x  , y  ); 
     
    77                g.lineTo(x+w, y+h); 
    88                g.lineTo(x  , y+h); 
     9                if (close) 
     10                        g.lineTo(x, y); 
    911        } 
    1012} 
  • lang/legacy-actionscript/as2draw/build.bat

    r3273 r3302  
    1 mtasc -version 7 -swf AS2Draw.swf -main AS2Draw.as -header 480:224:30 
     1mtasc -version 7 -swf AS2Draw.swf -main AS2Draw.as -header 480:288:30 
  • lang/legacy-actionscript/as2draw/index.html

    r3273 r3302  
    2020        <body> 
    2121                <div class="canvas-container"> 
    22                         <object data="./AS2Draw.swf" type="application/x-shockwave-flash" width="480" height="224"> 
     22                        <object data="./AS2Draw.swf" type="application/x-shockwave-flash" width="480" height="288"> 
    2323                                <param name="movie" value="./AS2Draw.swf" /> 
    2424                                <param name="autostart" value="true" />