A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: How to stretch a rectangle with actionscript?

  1. #1
    (YANKEES SUCK)
    Join Date
    Mar 2003
    Location
    beantown
    Posts
    55

    How to stretch a rectangle with actionscript?

    Code:
    function CreateRectangle (X, Y, XLength, YLength)
    {
    	
    	this.createEmptyMovieClip("rectangle_mc", 0);
    	drawRoundedRectangle(rectangle_mc, XLength, YLength, 0, 0xFFFFFF, 50);
    	rectangle_mc._x = X;
    	rectangle_mc._y = Y;
    	function drawRoundedRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, cornerRadius:Number, fillColor:Number, fillAlpha:Number):Void {
        with (target_mc) {
    
            beginFill(fillColor, fillAlpha);
            moveTo(cornerRadius, 0);
            lineTo(boxWidth - cornerRadius, 0);
            curveTo(boxWidth, 0, boxWidth, cornerRadius);
            lineTo(boxWidth, cornerRadius);
            lineTo(boxWidth, boxHeight - cornerRadius);
            curveTo(boxWidth, boxHeight, boxWidth - cornerRadius, boxHeight);
            lineTo(boxWidth - cornerRadius, boxHeight);
            lineTo(cornerRadius, boxHeight);
            curveTo(0, boxHeight, 0, boxHeight - cornerRadius);
            lineTo(0, boxHeight - cornerRadius);
            lineTo(0, cornerRadius);
            curveTo(0, 0, cornerRadius, 0);
            lineTo(cornerRadius, 0);
            endFill();
    		}
    	}
    }
    Then I call it by this
    Code:
     
    CreateRectangle (120, 335, 520, 75);
    How do I slowly strech it?

    Thanks
    -Evan
    FOR GREAT, ABSORBING FUN, VISIT WWW.STUFFINITY.COM/GAMES

  2. #2

  3. #3
    Ronze Ronze's Avatar
    Join Date
    Oct 2002
    Location
    Copenhagen, Denmark
    Posts
    185
    You can stretch it simply by making the _width of the container MovieClip larger...
    --- Ronze ---

  4. #4
    (YANKEES SUCK)
    Join Date
    Mar 2003
    Location
    beantown
    Posts
    55
    I want to slowly stretch it though
    FOR GREAT, ABSORBING FUN, VISIT WWW.STUFFINITY.COM/GAMES

  5. #5
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Ronze- (good catch)

    ed- how?..like with another button click or something?

    you can then just EASE it then...but you'll have to have a way to input the sizes.. to want to tween to.

  6. #6
    Ronze Ronze's Avatar
    Join Date
    Oct 2002
    Location
    Copenhagen, Denmark
    Posts
    185
    ??... I thought he just wanted to make the box wider, and this could be done by calling the _width of the mc in a function e.g. within a setInterval or something...

    Don't understand your question whispers...
    --- Ronze ---

  7. #7
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    I thought he wants to 'tween' the square...and not have it 'jump' to a new size.??


    and in order for you to do that..you would need to know the NEW size of the square he wants no?

    right now..he only has a function that DRAWS his rectanlges on the stage at a predetermined size...right?

    so to EASE/TWEEN his current 'rectanlge' we need that clips size...AS WELL AS the NEW size he wants it to be...right?

    so right now he only calls that ONE fucntion to intially to create the rectangle..

    the needs to be a way for him to trigger the NEW size function..as well as what parameters (size) he wants.

    so is this another button with a hardcoded function? input fields? what & how is this new function goin got be triggered. my comment to you was, good catch on seeing that is was being created in a containerClip (I missed that)..and since this is a redraw function, using your suggestion was a good idea..

  8. #8
    Ronze Ronze's Avatar
    Join Date
    Oct 2002
    Location
    Copenhagen, Denmark
    Posts
    185
    :-)
    --- Ronze ---

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