Saturday, November 21, 2009

Control Adjust Flash Player Window Size

When you create Shockwave File (SWF) in Adobe Flash (say in version CS4) and play it in Flash Player in non-bowser mode, the Player Window Size gets automatically adjusted to the values specified by the Stage Width and Height parameters in your flash file.

Take a look at the following two SWFs created in Flash CS4. They are the same Tinting Flash files - only difference being the Stage Width value. The first one has width value 250 while the second one 435, height being 292 for both.

The first one simply Crops the image but there is no scroll bar.





However, things are little different when you create SWF using Flex. If you create say the Line Chart in Flex Builder 3 and play it in Flash Player, it does not fit automatically in the Window and you get a Scroll Bar. The user needs to drag the Player Window or make it full screen to have a full view.



To Control and Adjust Flash Player Window Size so that it fits nice and fine with your application, all you need to do is to define Width and Height values of your application at the very beginning of your MXML code.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top" horizontalAlign="center" backgroundGradientColors="[0x000000,0x323232]" width="650" height="265">