Changeset 3364

Show
Ignore:
Timestamp:
12/20/07 20:26:12 (13 months ago)
Author:
gyuque
Message:

lang/legacy-actionscript/as2draw: implemented stack-based drawable.

Location:
lang/legacy-actionscript/as2draw
Files:
2 modified

Legend:

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

    r3363 r3364  
    44        private var mMC:MovieClip; 
    55        private var mMStack:MovieClipStack; 
     6        private var mCurrentDrawingMC:MovieClip; 
    67        private var mSize:Object; 
    78        private var mPixBuf:PixelBuffer; 
     
    1819                 
    1920                mMStack = new MovieClipStack(mMC); 
     21                mCurrentDrawingMC = null; 
    2022                 
    2123                mPixBuf = new PixelBuffer(aW, aH, mMC); 
     
    5456        { 
    5557                mDragData.dragging = false; 
     58                commit(); 
    5659        } 
    5760         
     
    6770        private function renderLine(x1:Number, y1:Number, x2:Number, y2:Number) 
    6871        { 
     72                var g:MovieClip; 
     73                 
     74                if (!mCurrentDrawingMC) 
     75                        mCurrentDrawingMC = mMStack.pushNew(); 
     76                 
     77                g = mCurrentDrawingMC; 
     78         
    6979                var ofs:Array = PEN_OFFSET_1; 
    7080                var l:Number = ofs.length>>1; 
     
    8393                                x2 +dx, y2 +dy, 0, mCurrentPen.color); 
    8494 
    85                         mMC.lineStyle(0, mCurrentPen.color); 
    86                         mMC.moveTo(x1+dx, y1+dy); 
    87                         mMC.lineTo(x2+dx, y2+dy); 
    88                         mMC.lineTo(x2+dx, y2+dy+1); 
     95                        g.lineStyle(0, mCurrentPen.color); 
     96                        g.moveTo(x1+dx, y1+dy); 
     97                        g.lineTo(x2+dx, y2+dy); 
     98                        g.lineTo(x2+dx, y2+dy+1); 
    8999                } 
    90100        } 
     
    107117                mMC.endFill(); 
    108118        } 
     119         
     120        private function commit() 
     121        { 
     122                mCurrentDrawingMC = null; 
     123        } 
    109124}