Skip navigation
Currently Being Moderated

True cross-platform

Apr 18, 2012 10:59 AM

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 )

                                        fixWidth();

                              if( (w_ratio - h_ratio) < n_tolerance )

                                        fixHeight();

 

 

                              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;

                              addChild(mainApp);

                    }

 

                    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.

 
Replies
  • Currently Being Moderated
    Apr 18, 2012 11:47 AM   in reply to he11f1re

    You're getting a percentage which when compiled on a device outside iOS will definitely have a good chance of being irregular. iPads are 4:3, Andoid Tablets are typically HD (16:9). Your scaling will then result in stretching.

     

    With spark components you can always give them a percentage or absolute width as well as use layouts and attributes (in the IDE) to anchor them to specific positions. That doesn't solve your problem entirely as a good ratio on a tablet is most certainly not the same as a phone.

     

    You need to define cross-platform. Plan to use a MVC pattern and get ready to customize some usable views for as many display aspects as you can. There's no real magic there, just the same old hard work that spark anchoring and dynamic widths can help a bit with.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2012 7:22 AM   in reply to he11f1re

    You should go to the adobe page on the 3d frameworks and look at their showcases. Plenty of examples are there

     

    http://www.adobe.com/devnet/flashplayer/stage3d.html

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points