package ch12_1
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
public class Poem extends MovieClip
{
var tf:TextField = new TextField();
public function Poem()
{
tf.autoSize ="left";
tf.wordWrap = true;
tf.width =stage.stageWidth;
var format:TextFormat = new TextFormat();
format.leftMargin =10;//左边留白 10
format.color =0x0000FF;
format.align ="justify";//自动两端对齐
format.size =60;//字号60
format.font ="华文细黑";
format.letterSpacing =5;//字间距5
format.leading =5;//行间距5
tf.defaultTextFormat =format;
/* tf.text ="日照香炉生紫烟,"+
"遥看瀑布挂前川。"+
"飞流直下三千尺,"+
"疑是银河落九天。";*/
tf.text ="日照香炉生紫烟,"
tf.appendText("遥看瀑布挂前川。");
tf.appendText("飞流直下三千尺,");
tf.appendText("疑是银河落九天。");
addChild(tf);
stage.addEventListener(MouseEvent.CLICK,change);
}
private function change(e:MouseEvent):void
{
var f2:TextFormat = new TextFormat();
f2.color =0xFF0000;
tf.setTextFormat(f2,0,7);//使用f2的格式,从第1个字到第7个字。
}
}
}
AS3 打印一首诗
最新推荐文章于 2024-04-03 21:06:29 发布