
208
CHAPTER 11
By default, Flash SWFs scale when resized—not the behavior expected by users. Go ahead and try
resizing the
Draw Rect panel you just created. All of the elements should scale in size, as if you had
zoomed in on the stage in Flash. Scaling can easily be prevented by adding the following ActionScript
to Frame 1 of the
Actions layer in the movie’s main timeline:
Stage.scaleMode = "noScale";
Stage.align = "TL";
The first property tells Flash not to scale/stretch its content when resized; the second property tells
Flash to anchor its content to the top- left (TL) corner of the Flash Player window. Go ahead and
update your
Draw Rect panel with these changes, republish, and then test the panel. Figure 11-10
shows these settings in action.
Figure 11‑10. Basic scaleMode and align properties set
The panel is no longer scaling, but none of the elements on the stage actually react to the resizing,
they just don’t scale. Cosmetically, this is definitely an improvement, but it still doesn’t get us all the
way there. Take the
Add Rect button, for example. It is common practice to have the main dialog
command button anchored to the lower- right corner of the dialog window. This can be achieved by
handling the stage object’s onResize event in ActionScript:
Stage.onResize = function()
{
// Define a common margin
var MARGIN:Number = 10;
// Manually update the position of executeJSF_btn
executeJSF_btn._left = Stage.width – executeJSF_btn.width – MARGIN;
executeJSF_btn._top = Stage.height – executeJSF_btn.height – MARGIN;
Kommentare zu diesen Handbüchern