Created
May 5, 2014 14:36
-
-
Save z-ohnami/23c73c526c9e8c323f3c to your computer and use it in GitHub Desktop.
use Font Resource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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