Changeset 3300

Show
Ignore:
Timestamp:
12/19/07 03:30:38 (13 months ago)
Author:
gyuque
Message:

lang/legacy-actionscript/as2draw: handled pen buttons.

Location:
lang/legacy-actionscript/as2draw
Files:
1 added
4 modified

Legend:

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

    r3276 r3300  
    1515        private function buildToolPalette(tp:ToolPalette) 
    1616        { 
     17                var _this = this; 
     18                var closure = function(b){_this.pushedPenButton(b);}; 
     19                 
    1720                var p1:PenButton = new PenButton(3); 
    1821                tp.addButton(p1); 
     22                p1.afterPush = closure; 
    1923 
    2024                var p2:PenButton = new PenButton(8); 
    2125                tp.addButton(p2); 
     26                p2.afterPush = closure; 
    2227 
    2328                var p3:PenButton = new PenButton(16); 
    2429                tp.addButton(p3); 
     30                p3.afterPush = closure; 
     31        } 
     32         
     33        private function pushedPenButton(aButton:PenButton) 
     34        { 
     35                 
    2536        } 
    2637 
  • lang/legacy-actionscript/as2draw/Drawable.as

    r3273 r3300  
    1 //import jp.javac.tools.*; 
    2  
    31class Drawable 
    42{ 
     
    2422        { 
    2523                mMC.beginFill(mBGColor); 
    26                 mMC.moveTo(0      , 0      ); 
    27                 mMC.lineTo(mSize.w, 0      ); 
    28                 mMC.lineTo(mSize.w, mSize.h); 
    29                 mMC.lineTo(0      , mSize.h); 
     24                U.rect(mMC, 0, 0, mSize.w, mSize.h); 
    3025                mMC.endFill(); 
    3126        } 
  • lang/legacy-actionscript/as2draw/PenButton.as

    r3276 r3300  
    33        private var mWidth:Number; 
    44        private var mMC:MovieClip; 
    5         private var buttonWidth:Number = 28; 
     5        private var buttonWidth:Number  = 28; 
     6        private var buttonHeight:Number = 23; 
     7        private var mSelectionColor:Number = 0xddeeff; 
     8        private var mSelected:Boolean; 
     9         
     10        public var afterPush:Function; 
    611         
    712        public function PenButton(aWidth:Number) 
     
    1015        } 
    1116         
     17        public function getWidth() 
     18        { 
     19                return mWidth; 
     20        } 
     21         
    1222        public function createView(aParent:MovieClip, aIndex:Number) 
    1323        { 
    1424                mMC = aParent.createEmptyMovieClip("pen-button-w"+mWidth, aIndex); 
    15                 drawSymbol(mMC); 
     25                drawSymbol(mMC, true); 
    1626                mMC.useHandCursor = false; 
     27                 
     28                var _this = this; 
     29                mMC.onPress = function(){_this.onMouseDown()}; 
    1730                return mMC; 
    1831        } 
    1932         
    20         private function drawSymbol(g:MovieClip) 
     33        public function setSelected(b:Boolean) 
    2134        { 
    22                 var c:Number = (buttonWidth-4)/2; 
     35                mSelected = b; 
     36                drawSymbol(mMC, b); 
     37        } 
     38         
     39        private function onMouseDown() 
     40        { 
     41                if (afterPush) 
     42                        afterPush(this); 
     43        } 
     44         
     45        private function drawSymbol(g:MovieClip, selected:Boolean) 
     46        { 
     47                var cx:Number = buttonWidth/2; 
     48                var cy:Number = buttonHeight/2; 
     49         
     50                mMC.clear(); 
     51                 
     52                if (selected) { 
     53                        mMC.beginFill(mSelectionColor); 
     54                        U.rect(mMC, 0, 0, buttonWidth, buttonHeight); 
     55                        mMC.endFill(); 
     56                } 
     57                 
    2358                g.lineStyle(mWidth, 0x000000); 
    24                 g.moveTo(c+2,c); 
    25                 g.lineTo(c+2+0.5,c); 
     59                g.moveTo(cx,    cy); 
     60                g.lineTo(cx+0.5,cy); 
    2661        } 
    2762}