• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

True cross-platform

Explorer ,
Apr 18, 2012 Apr 18, 2012

Copy link to clipboard

Copied

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.

TOPICS
ActionScript

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2012 Apr 18, 2012

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 18, 2012 Apr 18, 2012

Copy link to clipboard

Copied

Thanks for clearing it up

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 19, 2012 Apr 19, 2012

Copy link to clipboard

Copied

I was wondering if you know any open source game which is cross platform and build with as3 afcourse ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2012 Apr 19, 2012

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines