3

Read that the default size should be 12px. Is this something about DPI? How to solve?

enter image description here

EDIT
Thank you folks, but this doesn't seams to be something related to the font size. It looks like its something about handling DPI because it happens with simple Sprites too and weirdly the colors on Android seams to use an inversed RGB sequence

enter image description here

The Main.hx:

package;

import openfl.display.DisplayObjectContainer;
import openfl.display.Sprite;
import openfl.display.StageAlign;
import openfl.display.StageScaleMode;
import openfl.events.Event;
import openfl.system.Capabilities;
import openfl.text.TextField;
import ru.stablex.ui.UIBuilder;

class Main extends Sprite
{   
    private var size: Float = 100;

    private var r: Sprite;
    private var g: Sprite;
    private var b: Sprite;

    public function new()
    {
        super();        
        addEventListener(Event.ADDED_TO_STAGE, addedToStage, false, 0, true);
    }

    private function addedToStage(event: Event): Void
    {
        stage.scaleMode = StageScaleMode.NO_SCALE;
        stage.align = StageAlign.TOP_LEFT;

        r = createSquare(this, 0x00FF0000, size);
        g = createSquare(this, 0x0000FF00, size);
        b = createSquare(this, 0x000000FF, size);

        stage.addEventListener(Event.RESIZE, resize, false, 0, true);
        resize(null);
    }

    private function resize(event: Event): Void
    {
        r.x = 0;
        r.y = 0;

        g.x = (stage.stageWidth / 2) - (size / 2);
        g.y = (stage.stageHeight / 2) - (size / 2);

        b.x = stage.stageWidth - size;
        b.y = stage.stageHeight - size;
    }

    private function createSquare(parent: DisplayObjectContainer, color: Int, size: Float): Sprite
    {
        var box: Sprite = new Sprite();

        box.graphics.beginFill(color);
        box.graphics.drawRect(0, 0, size, size);
        box.graphics.endFill();

        parent.addChild(box);

        return box;
    }
}
Leo Cavalcante
  • 2,327
  • 2
  • 22
  • 30

2 Answers2

2

You can use sp size unit, which always seems the same size on different dpi screens.

Ray Wang
  • 106
  • 4
2

Please try this.

 text.autoSize = "center";

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextFieldAutoSize.html

You can size Sprite size to 100%.

Auto size text field with Actionscript 3 -- This link can help you.

Uddhav P. Gautam
  • 7,362
  • 3
  • 47
  • 64