forked from: [Flash 10] Text Engine Demo
forked from [Flash 10] Text Engine Demo (diff: 43)
Flash 10 Text Engine Demo @author Yasu (clockmaker) Flash 10 の Text Engine を使うと 従来の Text Field のように拡大や移動時に ジャギらないという実験デモ
ActionScript3 source code
/**
* Copyright s8t1h12akj ( http://wonderfl.net/user/s8t1h12akj )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/c01i
*/
package {
import com.bit101.components.*;
import flash.display.*;
import flash.system.*;
import flash.text.engine.*;
import flash.text.*;
import org.libspark.betweenas3.BetweenAS3;
import org.libspark.betweenas3.easing.Elastic;
import org.libspark.betweenas3.tweens.ITween;
[SWF(frameRate=60)]
public class Main extends Sprite {
static private const MSG:String = "函館@あき爺の回転文字テスト!";
// 設定値
var txtColor:uint = 0x000033;
var fontSize:uint = 24;
// フォント情報
var font:FontDescription = new FontDescription( "メイリオ,ヒラギノ角ゴ Pro W3,MS Pゴシック,_ゴシック,_等幅", FontWeight.NORMAL, FontPosture.NORMAL, FontLookup.DEVICE, RenderingMode.NORMAL );
// 整列フォーマット情報
var format:ElementFormat = new ElementFormat( font, fontSize, txtColor );
format.locale = "ja";
// 段組
var textBlock :TextBlock = new TextBlock();
// 字の整列方向(縦書き)
textBlock.lineRotation = TextRotation.ROTATE_0;
textBlock.textJustifier = new EastAsianJustifier("ja", LineJustification.UNJUSTIFIED );
// 文字情報設定
textBlock.content = new TextElement( MSG, format );
var sp:Sprite = new Sprite();
// 実際に整形と配置
var i:uint = 0;
var textLine:TextLine = textBlock.createTextLine( null, 500 );
while (textLine) {
sp.addChild( textLine );
textLine.x = -textLine.width / 2;
textLine = textBlock.createTextLine(textLine, 500 );
}
return sp;
}
private function createTextField():Sprite {
var fontName:String = "_ゴシック";
if (Capabilities.os.indexOf("Vista") != -1) fontName = "メイリオ";
if (Capabilities.os.indexOf("XP") != -1) fontName = "MS Pゴシック";
if (Capabilities.os.indexOf("Mac") != -1) fontName = "ヒラギノ角ゴ Pro W3";
var format:TextFormat = new TextFormat(fontName, 24);
var text:TextField = new TextField();
text.width = 400;
text.text = MSG;
text.x = -text.width / 2;
text.y = -text.textHeight / 2;
text.autoSize = TextFieldAutoSize.CENTER;
text.setTextFormat(format);
var sp:Sprite = new Sprite;
sp.addChild(text);
return sp;
}
}
}