All pastes #501838 Raw Edit

Untitled

public text v1 · immutable
·published 2007-05-22 07:17 UTC
rendered paste body
import mx.utils.Delegate;

class Draw2 extends MovieClip {
    var isPainting:Boolean;
    var theBrush:Object;
	private var mc:MovieClip;
    public function Draw2 (target:MovieClip, depth:Number) {
		theBrush = new Object ();
        mc = target.createEmptyMovieClip ("painting" + depth, depth);
       trace(mc)
        theBrush.onMouseDown = Delegate.create(this,mouseDown);
        theBrush.onMouseMove = Delegate.create(this,mouseMove);
        theBrush.onMouseUp = Delegate.create(this,mouseUp);
        };
        Mouse.addListener (theBrush);
    }
    public Function mouseDown():void {
            this.isPainting = true;
            trace(this.isPainting);
            mc.moveTo (_xmouse, _ymouse);
            mc.lineTo (_xmouse + 1, _ymouse + 1);
            mc.lineStyle (1, 100, 100);
    }

    public Function mouseMove():void {
            if (this.isPainting) {
                mc.lineTo (_xmouse, _ymouse);
            }
    }
    
    public Function mouseUp():void {
            trace(this.isPainting);
            this.isPainting = false;
    }
}