Skip to content

Instantly share code, notes, and snippets.

@z-ohnami
Created May 5, 2014 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z-ohnami/23c73c526c9e8c323f3c to your computer and use it in GitHub Desktop.
Save z-ohnami/23c73c526c9e8c323f3c to your computer and use it in GitHub Desktop.
use Font Resource
package sample;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.TextFormatAlign;
import flash.text.Font;
import openfl.Assets;
import flash.events.Event;
class Act001 extends Sprite
{
private var _text:TextField;
public function new()
{
super();
addEventListener(Event.ADDED_TO_STAGE, added);
}
private function added(event:Event)
{
removeEventListener(Event.ADDED_TO_STAGE, added);
var font = Assets.getFont ("font/misaki_mincho.ttf");
var format:TextFormat = new TextFormat();
format.align = TextFormatAlign.CENTER;
format.size = 30;
format.bold = true;
format.font = font.fontName;
_text = new TextField();
// setTextFormat or defaultTextFormat 順番に注意
// _text.defaultTextFormat = format;
_text.text = 'z.ohnamiです。\nIs there any problem ?';
_text.width = stage.stageWidth;
_text.height = 60;
_text.setTextFormat(format);
_text.textColor = 0x0000FF;
addChild(_text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment