A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: control a drawing script

  1. #1
    Member
    Join Date
    Oct 2005
    Posts
    59

    control a drawing script

    I would like to control this drawing script. Now the script allows one to draw anywhere on the site. The script is placed in a frame. Can I have the user only draw in a controled area? And would it be possible for one to put a code on a button to allow on a take a screen shot of the site.


    here is the code.

    Thank you for your help.


    // 1. SETTING THINGS
    // ----------------
    _root.createEmptyMovieClip("line",1);

    // 2. EVENTS IN _ROOT:
    // ------------------------
    _root.onMouseDown = function(){
    line.moveTo(_xmouse,_ymouse);
    line.lineStyle(0,0x000000,100);
    this.onEnterFrame = function(){
    line.lineTo(_xmouse,_ymouse);
    }
    }
    _root.onMouseUp = function(){
    this.onEnterFrame = null;
    }
    // 3. BUTTON "ERASE":
    // --------------------
    buttonErase.onPress = function(){
    _root.line.clear();
    }

  2. #2
    Member
    Join Date
    Aug 2004
    Posts
    33
    //here's a quick an easy solution, maybe not the best
    //create an empty movie clip that will act as a mask.
    //draw a shape in the mask
    //apply the mask to the line mc
    //I also added a border mc so you could see where to draw
    //as far as a screen shot, don't think so with just flash
    //but you could record all the _x, _y points and store it in an XML file
    //and then use some actionscript to redraw the lines from the data

    // 1. SETTING THINGS
    // ----------------
    //create shape for mask
    _root.createEmptyMovieClip("mask",2);
    mask._x=100;
    mask._y=100;
    mask.beginFill(0x000000,100)
    mask.moveTo(0,0);
    mask.lineTo(0,200);
    mask.lineTo(200,200);
    mask.lineTo(200,0);
    mask.lineTo(0,0);
    mask.endFill();
    //end shape for mask


    //add border
    _root.createEmptyMovieClip("border",3);
    border._x=100;
    border._y=100;
    border.lineStyle(0,0xff0000,100)
    border.moveTo(0,0);
    border.lineTo(0,200);
    border.lineTo(200,200);
    border.lineTo(200,0);
    border.lineTo(0,0);
    //end add border

    _root.createEmptyMovieClip("line",1);

    //ste the mask to the line mc
    _root.line.setMask(mask);

    // 2. EVENTS IN _ROOT:
    // ------------------------
    _root.onMouseDown = function(){
    line.moveTo(_xmouse,_ymouse);
    line.lineStyle(0,0x000000,100);
    this.onEnterFrame = function(){
    line.lineTo(_xmouse,_ymouse);
    }
    }
    _root.onMouseUp = function(){
    this.onEnterFrame = null;
    }
    // 3. BUTTON "ERASE":
    // --------------------
    buttonErase.onPress = function(){
    _root.line.clear();
    }

  3. #3
    Member
    Join Date
    Oct 2005
    Posts
    59
    Thank you Jamtv....
    would anyone be kind enough to put a quick swf. file together to show me how this works. I still can't fiqure out the steps to put all of this together.

    best,

    paul

  4. #4
    Member
    Join Date
    Aug 2004
    Posts
    33
    Just paste my previous post into frame 1 of your actions layer. The only thing that won't work is the clear button.

  5. #5
    Member
    Join Date
    Oct 2005
    Posts
    59
    Thanks Jamvt... all the best

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center