dcsimg
A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: drawing rounded rectangles in actionscript

  1. #21
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    hmm, can't edit posts anymore, didn't know that, here is better example of the previous post http://docs.google.com/Doc?id=dhk9csv4_161ffnnmw
    if you find some of my ideas weird, look at my avatar for the reason

  2. #22
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try something along these lines -

    draw the object with drawing API

    this.onEnterFrame = function(){ // loop to check if clip has instanciated
    if(drawnClip._width>0){ // empty clip has width = 0
    //apply animation
    this.onEnterFrame = null; // kill the loop
    };

    hth

  3. #23
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    hmmmm, sorry, but where would i put that??
    if you find some of my ideas weird, look at my avatar for the reason

  4. #24
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    on the main timeline, same frame as the drawingAPI / animation code

  5. #25
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    sorry, i still can't figure out how that would allow the created shape to be animated....
    if you find some of my ideas weird, look at my avatar for the reason

  6. #26
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you would need to check that the created clip has properties (width>0)
    before you can animate it, hence the onEnterFrame loop.

    for a simple drawing animation, adapt this method -
    Code:
    this.createEmptyMovieClip("line1",1);
    this.createEmptyMovieClip("holder2",2);
    holder2.createEmptyMovieClip("line2",1);
    this.createEmptyMovieClip("holder3",3);
    holder3.createEmptyMovieClip("line3",1);
    this.createEmptyMovieClip("line4",4);
    xPos = 0;
    yPos = 390;
    
    holder2.line2.onEnterFrame = function(){
    _root.xPos+=10;
    speed = 20;
    h<360 ? h+=speed  : h=360;
    v<360 ? v+=speed : v=360;  
    v==360 ? delete this.onEnterFrame : null;
    
    with(line1){
    clear();
    _x = xPos;
    _y = yPos;
    lineStyle(2, 0xFF0000, 100); // red - left
    lineTo(0,-v );
    }
    
    with(holder2.line2){
    clear();
    _x = xPos;
    _y = yPos;
    lineStyle(2, 0x0000FF, 100); // blue - top 
    lineTo(h, 0);
    }
    
    with(holder3.line3){
    clear();
    _x = xPos;
    _y = yPos;
    lineStyle(2, 0x000000, 100); // black - right
    lineTo(0, v );
    }
    
    with(line4){
    clear();
    _x = xPos;
    _y = yPos;
    lineStyle(2, 0x0000FF, 100); // blue - bottom
    lineTo(h,0 );
    }
    
    holder2._y -=speed;
    holder3._x +=speed;
    holder3._y -=speed; // move the clips
    
    };
    hth

  7. #27
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    ok then, that makes sense

    thnx for the explanation

    (i'll play around with that later (too much homework atm that i should be concentrating on :P)

    though one question for the moment, is

    condition ? action1 : action2

    the same as

    if (condition) {
    action1
    } else {
    action2
    }

    ??

    (i think i've seen that before, but i'm not sure).....
    if you find some of my ideas weird, look at my avatar for the reason

  8. #28
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    also, is it possible to create a function where it's arguements in relation to what arguements you put in ??

    i don't think i explained that too well, so i'll give a better description

    say, if you have a function draw(); and this function has many arguements, the first of which is "action"

    so then, if action = "circle", then the arguements would be

    function draw(action, startx, starty, radiusx, radiusy, speed)

    whereas, if action = "move", then arguements would be

    function draw(action, endx, endy, speed)

    etc, etc ..... ??
    (and then be even better and have the little tooltips that the prebuilt functions have ?? (as in like gotoAndStop, etc )
    if you find some of my ideas weird, look at my avatar for the reason

  9. #29
    Crazy Guy delfick's Avatar
    Join Date
    Feb 2004
    Location
    Best side of the best country (Western Australia)
    Posts
    165
    i've really got to go cold turkey with my computer or something..............i couldn't concentrate on homework, and quickly did this

    boxDraw(50, 50, 200, 300, 0.2, 2, 0x000000, 0xFFFFFF);
    function boxDraw(xPos, yPos, maxh, maxv, speed, lineWidth, lineColour, areaColour) {
    this.createEmptyMovieClip("fill", 1);
    this.createEmptyMovieClip("l_bottom", 2);
    this.createEmptyMovieClip("l_right", 3);
    this.createEmptyMovieClip("l_left", 4);
    this.createEmptyMovieClip("l_top", 5);
    v = 0;
    l_bottom.onEnterFrame = function() {
    if (Math.abs(maxv-v)>1) {
    v += (maxv-v)*speed;
    } else {
    v = maxv;
    delete this.onEnterFrame;
    }
    fill.clear();
    fill.beginFill(0x0000FF, 5);
    fill.moveTo(xPos+lineWidth, yPos+(lineWidth/2));
    fill.lineTo(xPos+maxh-lineWidth, yPos+(lineWidth/2));
    fill.lineTo(xPos+maxh-lineWidth, yPos+v-(lineWidth/2));
    fill.lineTo(xPos+lineWidth, yPos+v-(lineWidth/2));
    fill.endFill();
    with (l_left) {
    clear();
    _x = xPos;
    _y = yPos;
    lineStyle(lineWidth, lineColour, 100);
    // red - left
    lineTo(0, v);
    }
    with (l_top) {
    clear();
    _x = xPos;
    _y = yPos;
    lineStyle(lineWidth, lineColour, 100);
    // blue - top
    lineTo(maxh, 0);
    }
    with (l_right) {
    clear();
    _x = xPos+maxh;
    _y = yPos;
    lineStyle(lineWidth, lineColour, 100);
    // black - right
    lineTo(0, v);
    //10, 500, h, 0);
    }
    with (l_bottom) {
    clear();
    _x = xPos;
    _y = yPos+v;
    lineStyle(lineWidth, lineColour, 100);
    // blue - bottom
    lineTo(maxh, 0);
    }
    // move the clips
    };
    }
    which fits a purpose for something else i might do one day.....(when i actually have free time )

    thnx for your help

    now, back to homework.....good old chemistry....*sigh*
    if you find some of my ideas weird, look at my avatar for the reason

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