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:

Exey said...

I'm often face with this problem. Thank you

Anonymous said...

Thank you, that helped a lot.

Ickydime said...

No problem, glad to hear people are using it.

Anonymous said...

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;
}

Ickydime said...

@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. :)

Anonymous said...

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/

Ickydime said...

@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.

Lîtus said...

Brilliant! Thnx!!

Anonymous said...

Thanks, you just saved me hours of hair pulling!