Auto-Resize of Flash Lite application
I was asked recently by a mobile content developer if Flash Lite app can auto-resize based on the mobile phone screen orientation. Some mobile phones come in landscape mode, others come in portrait mode. Then there are also phones like the Treo that have square screen. And that is not all, some phones like i-mate JASJAM can change the screen modes (portrait/landscape) when the keyboard slides in and out. So does that mean we have to create different versions of the same app for these different phones? Answer is no. Flash Lite app can detect screen orientation on app starts up and when the screen orientation changes. See below code for an example:
// To respond to landscape, portrait and square viewing
Stage.scaleMode = “noScale”;
var stageListenerObj:Object = new Object();
stageListenerObj.onResize = function () {
if (Stage.width > Stage.height){
gotoAndStop(”landscape”);
} else if (Stage.width < Stage.height) {
gotoAndStop(”portrait”);
} else {
gotoAndStop(”square”);
}
}
Stage.addListener(stageListenerObj);
Download the Flash Lite player for Nokia S60 series phone and Windows Mobile phone here

I suggest before you post code online, you check if it works! It you have a big mistake: instead of “} else if (Stage.width > Stage.height) {” you need to say “} else if (Stage.width with a < because portrait means width < height
[...] landscape and portrait mode. There is a nice code snippet here, but there is a big boo-boo in: Auto-Resize of Flash Lite application watch out for that else statement, it should be else if [...]
misha the machine › Mobile software development said this on August 16, 2007 at 4:37 am |
Oops. Thanks for pointing out the typo. Yes, it should bethe smaller than sign, not the bigger than sign . My mistake. Now updated on the page.
Thanks for the tips.
I want to ask you what is the best workflow if I have convert a windows flash content for mobile device?
Rvk,it depends. While a desktop flash application can be scaled to fit the screen of the mobile, it may not be the best to have evrything cramped into a small screen. I always feel that we should design with a target medium in mind. What looks good on a 15 inche display may not necessarily be good for a 3 inch display.
If you have an existing desktop flash file, you may want to first convert the app based on the device profile that we are targeting. Then publish the content to test it in device central and see what needs to get changed.