Thursday, July 10, 2008

Update: Scale9Grid Class

delizade requested a Test.fla for the Scale9Grid class I posted awhile back.

In making the Test I found a few bugs... mainly the scaleY was not working at all. Sorry about that if anyone tried it out. I fixed the class and reposted them online.

Class: Scale9Mask.as
Swf: Scale9MaskTest.swf
FLA (you will need Tweener): Scale9MaskTest.fla

Let me know if you run into any issues.

9 comments:

  1. I'm often face with this problem. Thank you

    ReplyDelete
  2. Thank you, that helped a lot.

    ReplyDelete
  3. No problem, glad to hear people are using it.

    ReplyDelete
  4. Thanks so much for the code, I just added "set width / height"

    override public function set width(width : Number) : void {
    innerWidth = width - leftMargin - rightMargin;

    topRectangle.width = mainRectangle.width = bottomRectangle.width = innerWidth;

    var newLeft : Number = mainRectangle.x + mainRectangle.width;
    topRightCorner.x = newLeft;
    bottomRightCorner.x = newLeft;

    if(bottomRightRadius > 0) {
    bottomRightCorner.x += rightMargin;
    }
    rightRectangle.x = newLeft;
    }

    override public function set height(height : Number) : void {
    innerHeight = height - topMargin - bottomMargin;

    leftRectangle.height = mainRectangle.height = rightRectangle.height = innerHeight;

    var newTop : Number = mainRectangle.y + mainRectangle.height;
    bottomLeftCorner.y = newTop;
    if(bottomLeftRadius > 0) {
    bottomLeftCorner.y += leftMargin;
    }
    bottomRightCorner.y = newTop;
    bottomRectangle.y = newTop;
    }

    ReplyDelete
  5. @Rudy

    Thanks for the additional code. I appreciate it. I dropped it in (hope you don't mind). Didn't get a chance to really test it, but looks right like it should be right. :)

    ReplyDelete
  6. Many thanks for you class, this is very handy ..
    I just have a little issue with scaling factors, when I try to scale your Scale9Mask along with other image, it doesn't scale properly ..
    you'll find a demo here :
    http://interactive-developer.com/blog/2008/09/16/scale9grid-with-masking/

    ReplyDelete
  7. @xvisage
    Appreciate your feedback and blog post.

    Good catch on the scale children bug, judging by the comments on a previous post, it looks like scaling children in scale9Grid doesn't work in Flash either... not just the class I threw together.

    ReplyDelete
  8. Thanks, you just saved me hours of hair pulling!

    ReplyDelete