4 Replies Latest reply: Apr 19, 2012 7:22 AM by sinious RSS

    True cross-platform

    he11f1re Community Member

      Hello everyone

      My question is very direct :

          Which is the best way to develop a cross platform air application ?

      I am currently working in an actionscript mobile project (only actionscript) and would like it better,

      to make the program fit the screen of the user's device(scaling) within some tolerance without breaking

      the aspect ratio.

      Which is the best way to do it in actionscript and if not possible than what's the best way in flex using mxml?

      Also I wanted to note that I have a lot of bitmaps used in app and wouldn't like to provide different set of resolutions.


      My current code in the MainClass is:


      package {


                import com.MainApp;


                import flash.display.Sprite;

                import flash.display.StageQuality;


                [SWF(backgroundColor='#333333', frameRate='60')]


                public class Main extends Sprite {


                          /* Embed tag per te ngjitur fontet e perdorura ne aplikacion. */


                          [Embed(source  ='../lib/DK Crayon Crumble.TTF', fontFamily="chalk", embedAsCFF="false")]

                          public var chalk:Class;

                          [Embed(source ='../lib/Harabara.TTF', fontFamily="harabaraBold", embedAsCFF="false")]

                          public var harabaraBold:Class;

                          [Embed(source ='../lib/helr45w.TTF', fontFamily="helvetica", embedAsCFF="false")]

                          public var helvetica:Class;



                          /* Percaktohet gjeresia dhe lartesia baze e apliakcionit (nga e cila do dalin lartesite e duhura per pajisje te caktuara).

                           * Percaktohet toleranca per zmadhim ose zvogelim maksimal qe te mos prishet aspect ratio.

                           * Percaktohet toleranca negative qe sherben per raste shume te rralla kur pajisja mund te kete probleme ne aspect ratio. */


                          internal const tolerance:Number = .15;

                          internal const n_tolerance:Number = -.8;


                          private var deviceWidth:Number;

                          private var deviceHeight:Number;

                          private var w_ratio:Number;

                          private var h_ratio:Number;


                          public function Main() {


                                    deviceWidth = 960; //I was thinking to use system.capabilities.screenResolutionX

                                    deviceHeight = 540;


                                    w_ratio = deviceWidth / stage.stageWidth;

                                    h_ratio = deviceHeight / stage.stageHeight;


                                    if( (w_ratio - h_ratio) > tolerance )


                                    if( (w_ratio - h_ratio) < n_tolerance )




                                    trace(stage.stageWidth, stage.stageHeight);


                                    /*This is the Main App Class which does all the linking between classes.*/

                                    var mainApp:Sprite = new MainApp();

                                    mainApp.scaleX = w_ratio;

                                    mainApp.scaleY = h_ratio;




                          private function fixWidth():void


                                    deviceWidth = deviceHeight * ( stage.stageWidth/stage.stageHeight + tolerance );

                                    w_ratio = deviceWidth / stage.stageWidth;



                          private function fixHeight():void


                                    deviceHeight = deviceWidth * ( stage.stageHeight/stage.stageWidth + tolerance );

                                    h_ratio = deviceHeight / stage.stageHeight;






      It feels like I'm doing it wrong ... and indeed I lack a lot of experience ... waiting for your help.