flash on 2009-11-29
TextEngineを・・・
♥0 |
Line 36 |
Modified 2009-11-29 21:24:38 |
MIT License
archived:2017-03-29 10:25:15
ActionScript3 source code
/**
* Copyright foo9 ( http://wonderfl.net/user/foo9 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/sveF
*/
package
{
import flash.display.Sprite;
import flash.text.engine.*;
/**
*
* TextEngineを・・・
*
*/
[SWF(width="465", height="465", backgroundColor="0x000000", frameRate="24")]
public class TextEngineSample extends Sprite
{
private const TEXT_JP:String = "これはテキストエンジンのサンプル。";
private const TEXT_ENG:String = "This is TextEngineSample.";
public function TextEngineSample()
{
//フォント
var font:FontDescription = new FontDescription();
font.fontName = "_ゴシック"; // _ゴシック, 明朝, _等幅, _sans, _serif, _typewriter
font.fontPosture = FontPosture.NORMAL; //or FontPosture.ITALIC
font.fontWeight = FontWeight.BOLD; //or FontWeight.NORMAL
//
var format:ElementFormat = new ElementFormat();
format.fontDescription = font;
format.locale = "ja"; // ?
format.fontSize = 20;
format.alpha = 1.0;
format.color = 0xFFFFFF;
//
var element:TextElement = new TextElement(TEXT_JP, format);
var element2:TextElement = new TextElement(TEXT_ENG, format);
//段組
var block:TextBlock = new TextBlock();
block.content = element;
var block2:TextBlock = new TextBlock();
block2.content = element2;
//段組みの中に行を作成
var line:TextLine = block.createTextLine();
addChild(line);
var line2:TextLine = block2.createTextLine();
addChild(line2);
//line.x = 0;
line.y = format.fontSize;
line2.y = format.fontSize * 2;
}
}
}