Working with 9-slice scaling in ActionScript
In the following example, you use the drawing tools to draw a 300 pixel by 300 pixel square
which is resized by using 9-slice scaling. The square is split up into nine smaller squares, each
one approximately 100 pixels wide by 100 pixels high. When you resize the square, each
segment that isn't a corner expands to match the specified width and height.
To use 9-slice scaling with ActionScript:
1.
Create a new Flash document and save it as ninescale.fla.
2.
Drag a Button component into the current document's library.
3.
Select the Rectangle tool and draw a red square (300 pixels by 300 pixels) with a 15-pixel
black stroke on the Stage.
4.
Select the Oval tool and draw a purple circle (50 pixels by 50 pixels) with a 2-pixel black
stroke on the Stage.
5.
Select the purple circle and drag it into the upper-right corner of the red square
created earlier.
6.
Select the Oval tool and draw a new circle that is approximately 200 pixels by 200 pixels
and position it off of the Stage.
7.
Select the new circle on the Stage and drag it so that the circle's center-point is in the lower-
left corner of the square.
8.
Click outside of the circle instance to deselect the circle.
9.
Double-click the circle again to select it and press backspace to delete the shape and remove
a circular portion of the square.
10.
Using the mouse, select the entire red square and inner purple circle.
11.
Press F8 to convert the shape into a movie clip symbol.
12.
Give the movie clip on the Stage an instance name of my_mc.
558
Animation, Filters, and Drawings
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?