MANDAR

AS3.0: Run time Scale nine in Flash

Posted in Flash Designer by Mandar on May 28, 2009

Run time scale is possible in AS3.0 for Flash. see the following example.

Steps:

1. Create new Sprite

var sp:Sprite = new Sprite();

2. Fill as corner rediol rectangular shape

with(sp.graphics)
{
lineStyle(1,0×000000,1,true);
beginFill(0xff0000,.5);
drawRoundRect(0,0,100,50,15);
endFill();

}

3. set position into the stage.

sp.x = sp.y = 50;

4. Add into the stage

addChild(sp);

5. Set the scale nine grid

var slice9:Rectangle = new Rectangle(15,15,70,20)
sp.scale9Grid = slice9;

6. Change the shape of the rectangle onEnter event

addEventListener(Event.ENTER_FRAME,onLeave,false,0,true);

function onLeave(event:Event):void
{
sp.width = Math.max(mouseX – sp.x,31);
sp.height = Math.max(mouseY – sp.y,31);
}


Leave a Reply

You must be logged in to post a comment.