560 Animation, Filters, and Drawings
Next, you create a new Button component instance and give it an instance name of
small_button. Whenever you click this button, the movie clip that you created earlier
resizes to 100 pixels wide by 100 pixels high. The fourth section of code dynamically
creates a new Button instance named
large_button which, when clicked, resizes the
target movie clip to 450 pixels wide by 300 pixels high. The final section of code creates a
new Button instance that the user can toggle on and off. When the button is in the on
state, the 9-slice grid is applied. If the button is in the off state, the 9-slice grid is disabled.
14. Save the Flash document and select Control > Test Movie to test the SWF file.
This code example adds and positions three Button component instances on the Stage and
creates event listeners for each button. If you click the Large button with the 9-slice grid
disabled, you can see that the image becomes distorted and looks stretched. Enable the 9-
slice grid by clicking the toggle button and click the Large button again. With the 9-slice
grid enabled, the circle in the upper-left corner should no longer appear distorted.