dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: I keep posting this way too much, however I need help breaking down this code...

  1. #1
    Junior Member
    Join Date
    Oct 2005
    Location
    Toronto
    Posts
    16

    I keep posting this way too much, however I need help breaking down this code...

    I just figured how to make a drawing board in flash, but need some help with a few things:

    1. How do i keep the drawing inside of the canvas?

    2. How do i draw shapes?

    3. How can i make different sized brushes?

    I have attached the file, so if you can help, take a look at it and see what i'm doing wrong.
    Attached Files Attached Files

  2. #2
    Junior Member
    Join Date
    Oct 2005
    Location
    Toronto
    Posts
    16

    Need help with drawing board

    Hi guys,
    I'm trying to make a sketch pad, and it works. The only problem I'm having is that when I go to the help section, which is in the second frame, and go back to the first frame, it brings the curser back with it...so there's two cursors. Anyone know why and how I can fix that?

    Thanx,
    z?

  3. #3
    Junior Member
    Join Date
    Oct 2005
    Location
    Toronto
    Posts
    16

    Need help breaking down this code...

    Hi guys, I'm just learning actionscripting, and did a tutorial on how to make a drawing board. I was wondering if anyone has the time to break down the code for me so I could understand it a bit better. I've attached the swf. and the code below. I just just copy and paste the code and insert ur explanation above it...even if you don't know all of it...anything will help

    Thanks


    var x = y=lastx=lasty=0;
    var down = false;
    var k = 0;
    var smooth = 4;
    var chkSmooth = 2;
    var switchSmooth = false;
    var col = 0x00ff00;
    var thk = 5;
    var alpha = 100;
    var line = createEmptyMovieClip("line", 0);
    line.lineStyle(thk, col, alpha);


    Mouse.hide();
    pencil.swapDepths(99);
    hand.swapDepths(100)
    this.onMouseDown = function() {
    down = true;
    x = lastx=_xmouse;
    y = lasty=_ymouse;
    line.moveTo(lastx, lasty);
    };
    this.onMouseUp = function() {
    down = false;
    };

    this.onMouseMove = function() {
    line.lineStyle(thk, col, alpha);
    if (bg.hitTest(_xmouse, _ymouse, true)) {
    hand._visible = false;
    pencil._visible = true;
    pencil._x = _xmouse;
    pencil._y = _ymouse;
    if (down) {
    k++;
    if (k == 36) {
    k = 0;
    }
    if (k%smooth == chkSmooth) {

    line.curveTo(x, y, lastx=(x+_xmouse)/2, lasty=(y+_ymouse)/2);
    x = _xmouse;
    y = _ymouse;
    }
    }
    } else {
    pencil._visible = false;
    hand._visible = true;
    hand._x = _xmouse;
    hand._y = _ymouse;
    }
    };
    var kl:Object = new Object();
    kl.onKeyDown = function() {
    switchSmooth = !switchSmooth;
    if (switchSmooth) {
    smooth = 9;
    chkSmooth = 3;
    } else {
    smooth = 4;
    }
    chkSmooth = 2;
    };
    Key.addListener(kl);
    function checkDist(x, x2, y, y2):Number {
    return Math.round(Math.sqrt(Math.pow(x-x2)+Math.pow(y-y2)))
    }
    function moveMark(target:MovieClip):Void {
    mark.onEnterFrame = function() {
    this._x += (target._x-this._x)/6;
    this._y += (target._y-this._y)/6;
    };
    }

    //paint colors and name in dynamic txt box

    blue.onPress = function() {
    col = 0x0000ff;
    colText.text = "Your colour is: "+this._name;
    moveMark(this);
    };
    green.onPress = function() {
    col = 0x009900;
    colText.text = "Your colour is: "+this._name;
    moveMark(this);
    };
    pink.onPress = function() {
    col = 0xff00ff;
    colText.text = "Your colour is: "+this._name;
    moveMark(this);
    };
    purple.onPress = function() {
    col = 0x6600ff;
    colText.text = "Your colour is: "+this._name;
    moveMark(this);
    };
    yellow.onPress = function() {
    col = 0xffff00;
    colText.text = "Your colour is: "+this._name;
    moveMark(this);
    };
    red.onPress = function() {
    col = 0xcc0000;
    colText.text = "Your colour is: "+this._name;
    moveMark(this);
    };
    orange.onPress = function() {
    col = 0xff6600;
    colText.text = "Your colour is: "+this._name;
    moveMark(this);
    };
    cyan.onPress = function() {
    col = 0x00FFFF;
    colText.text = "Your colour is: "+this._name;
    moveMark(this);
    };

    // clears the page when clear button is pressed

    clear.onPress = function(){
    line.clear()
    }

  4. #4
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    Please dont post the same thread twice. I closed your other one (thread).

  5. #5
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    Also, that is a lot of code for someone to explain to you. Why dont you try reading the comments that the person put in there and then start playing around with the code to see what it all does. If you dont know what a function does, look it up either here by searching the forums or in an actionscript manual.

    Most of learning actionscript is figuring out what different code snippets do and playing around with them until you understand them.

  6. #6
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    ---
    Last edited by Dricciotti; 03-02-2006 at 01:25 PM. Reason: thread merged

  7. #7
    supervillain gerbick's Avatar
    Join Date
    Jul 2000
    Location
    undecided.
    Posts
    18,978
    liquidchik, you post this once more and you'll be banned.

    You've posted this same thread across Flashkit over 6 times.

    that's FIVE TIMES too many. Read the rules, post your question only once.

    [ Hello ] | [ gerbick ] | [ Ω ]

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