I have been working on a project with lots of round cornered cubes. They all have to scale so i apply scale9Grids. Making a new Scale9Grid everytime and not seeing the grid frustrated me enough to come up with a solution to all my problems.
Thus the birth of the Scale9Helper class.
This class can make a Scale9Grid for you and it can also visualize you grid. SO you can actually see how the Scale9Grid is layed out.
–
–
Usage:
Scale9Helper.setScaleGrid ( your sprite, offset from sprite border );
Scale9Helper.showScaleGrid( your sprite );
–
Code:
View CodeACTIONSCRIPT | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | //--------------------------------- // RACKDOLLLABS@2008 // Rackdoll - 10/12/2008 //--------------------------------- package { import flash.display.Sprite; import flash.geom.Rectangle; public class Scale9Helper { public static function setScaleGrid( target:Sprite, offset:uint ):void { var grid:Rectangle = new Rectangle( offset, offset, target.width - ( offset << 1 ), target.height - ( offset << 1 ) ); target.scale9Grid = grid; } public static function showScaleGrid( target:Sprite, lineColor:uint = 0x00ff00 ):void { var targetScaleRect:Rectangle = target.scale9Grid; target.graphics.lineStyle( 2, lineColor ); target.graphics.moveTo( 0, targetScaleRect.y ); target.graphics.lineTo( target.width, targetScaleRect.y ); target.graphics.moveTo( targetScaleRect.x, 0 ); target.graphics.lineTo( targetScaleRect.x, target.height ); target.graphics.moveTo( 0, targetScaleRect.y + targetScaleRect.height ); target.graphics.lineTo( target.width, targetScaleRect.y + targetScaleRect.height ); target.graphics.moveTo( targetScaleRect.x + targetScaleRect.width, 0 ); target.graphics.lineTo( targetScaleRect.x + targetScaleRect.width, target.height ); } } } |
–
Have fun with it

The [AS3.0] Scale9Grid Helper class by Script.it, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Netherlands License.

