Textfield text not showing in Android

Hello,

I’m new to Haxe and openfl, coming from as3. I’m trying to simply show text with textfield but when i build and run on android i don’t get text. It works fine for html5 and flash.
Here is the code to create the textfield.

        var tft:TextFormat = new TextFormat(null, 40);
        _label = new TextField();
        _label.defaultTextFormat = tft;
        _label.width = 200;
        _label.height = 60;
        _label.selectable = false;
       _label.border = true;
        _label.text = "Hello";
        _label.x =0;
        _label.y =0;

Haxe is 3.1…4
OpenFL is 3.0.0
Lime is 2.3.1

Thanks

Could try targeting Android with -Dlegacy?

If you are using FlashDevelop, click in the target drop-down and type “android -Dlegacy”, it should add it as an additional option on the list for you.

If you use the command-prompt or terminal, try “openfl test android -Dlegacy”

There was a similar problem on the lime issues forum https://github.com/openfl/lime/issues/256

Though the problem might be with haxeflixel …

The issue was the standard font not being deployed to android.

So try setting the font type (to something in your project)

1 Like

I’ve just resolved the null font name in the newer code, and should be released fairly soon. In the meantime, -Dlegacy might work, thanks :slight_smile:

I tried it with -Dlegacy and it works.

Thanks for the quick reply.

Hi i’m new to Haxe (but i really like it!) and have similar problem on ios. I use IntelliJ as my IDE and i’m compiling project directly from it. Just tried compile with -Dlegacy using Terminal but no luck, any suggestions ? By the way it works on Android :slight_smile:

libs:
Haxe: 3.1.3
openFL: 3.0.3
lime: 2.3.3

trivial code :smile:

package ;
import openfl.display.Sprite;
import openfl.text.TextField;
class Main extends Sprite
{
    var tf:TextField;
    public function new()
    {
        super();
        tf = new TextField();
        tf.text = "Hello";
        tf.textColor = 0xFF0000;
        addChild(tf);
    }
}

You tried openfl test ios -Dlegacy?

Thanks Joshua on quick replay!
openfl test ios -Dlegacy gives me:

Warning: Could not find template file: iphone/PROJ/haxe/Build.hxml
Warning: Could not find template file: iphone/PROJ/haxe
Warning: Could not find template file: haxe
Warning: Could not find template file: iphone/PROJ/Classes
Warning: Could not find template file: iphone/PROJ/Images.xcassets
Warning: Could not find template file: iphone/PROJ/PROJ-Entitlements.plist
Warning: Could not find template file: iphone/PROJ/PROJ-Info.plist
Warning: Could not find template file: iphone/PROJ/PROJ-Prefix.pch
Warning: Could not find template file: iphone/PROJ.xcodeproj
Build settings from command line:
    PLATFORM_NAME = iphoneos
    SDKROOT = iphoneos8.3

xcodebuild: error: The directory /Users/igdeman/bin/ios does not contain an Xcode project.

I guess it could not find test project files or i’m doing something wrong? Good news is i’m seeing my “Hello” text now, i’ve changed code to use custom font and used -Dlegacy.

package ;

import openfl.Assets;
import openfl.text.Font;
import openfl.text.TextFormat;
import openfl.display.Sprite;
import openfl.text.TextField;
class Main extends Sprite
{
    var t:TextField;
    var tf:TextFormat;
    var f:Font;
    public function new()
    {
        super();
        f = Assets.getFont("assets/fonts/vag.TTF");
        tf = new TextFormat(f.fontName, 46, 0xffffff);
        t = new TextField();
        t.defaultTextFormat = tf;
        t.text = "Hello";
        addChild(t);
    }
}