Size and color is different on Android

61 views
Skip to first unread message

Leo Cavalcante

unread,
Aug 13, 2017, 1:12:24 PM8/13/17
to Haxe
From left to right: flash, android, html5.<br>
Why does the elements on Android version looks smaller and the RGB order doesn't seams the same?


`Main.hx`:

```haxe
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;
}
}
```

`project.xml`:

```xml
<?xml version="1.0" encoding="utf-8"?>
<project>
<meta title="HelloOpenFl2" package="com.sample.helloopenfl2" version="1.0.0" company="Company Name" />
<app main="Main" path="Export" file="HelloOpenFl2" />
<source path="Source" />
<haxelib name="stablexui" />
    <haxelib name="openfl" />
    <haxelib name="actuate" />
<assets path="Assets" rename="assets" />
<android target-sdk-version="23" />
<architecture name="x86" if="android" />
</project>
```

Jeff Ward

unread,
Aug 17, 2017, 2:50:37 PM8/17/17
to Haxe
Ah good, I see you posted (and got a response) on the OpenFL forum:


Just linking from here for future readers' benefit. :)

Best,
-Jeff
Reply all
Reply to author
Forward
0 new messages