# scale9grid problem

**URL:** <https://forum.kirupa.com/t/scale9grid-problem/288716>\
**Category:** flash\
**Created:** [May 20, 2009, 4:12am UTC](https://forum.kirupa.com/t/scale9grid-problem/288716 "2009-05-20T04:12:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![probphp](https://avatars.discourse-cdn.com/v4/letter/p/e99b99/32.png) [@probphp](https://forum.kirupa.com/u/probphp)\
**Post date:** [May 20, 2009, 4:12am UTC](https://forum.kirupa.com/t/scale9grid-problem/288716/1 "2009-05-20T04:12:14Z")

</div>

hello all,  
i am trying to set scale9grid property of a mouse following rectangle in as3.  
i am drawing a rectangle by dragging mouse.  
can i set this rectangle scale9grid property?  
i have written the following code but it displaying argument error.  
i am using a helper class to set the scale9grid which is as follows:

“helper class”  
package lib  
{  
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 );  
}  
}  
}  
i am calling Scale9Helper.setScaleGrid(GL.activeObject, 1);  
from my main class.  
GL.activeObject always will hold the current drawing rectangle.  
NOTE that i am drawing the rectangle on mouse dragging event.  
If any body have any idea about it please share it with me.

thanks in advance
