1.建立文本对象并初始化
1 let txt:egret.TextField = new egret.TextField(); 2 txt.textColor = 0xffffff; 3 txt.size = 24; 4 txt.lineSpacing = 20; 5 this.addChild(txt); 6 txt.x = 30; 7 txt.y = 100;
2.设置文本的混合样式
1 txt.textFlow = [ 2 {text: "一首告白小诗 ", style: {"size": 40,textColor:0x000066}}, 3 {text:'作者:鲁米 ',style:{"size":30,textColor:0xFF6666,fontFamily:"楷体",underline:true}}, 4 {text:'译者:梁永安 ',style:{"size":25,textColor:0x33CC33,fontFamily:"微软雅黑"}}, 5 {text:'我们一生都在互望着对方的脸 ',style:{"size":28,textColor:0x66CCFF}}, 6 {text:'今天也是如此。 ',style:{"size":28}}, 7 {text:'我们是怎样守住这个',style:{"size":28,textColor:0x66CCFF}}, 8 {text:'爱',style:{"size":50,textColor:0xFF3300,strokeColor:0xFFFF66,stroke:2}}, 9 {text:'的秘密的呢? ',style:{"size":28,textColor:0x66CCFF}}, 10 {text:'我们以眉传话, ',style:{"size":28,textColor:0x99CC66,italic:true}}, 11 {text:'以眼聆听。 ',style:{"size":30,textColor:0xFFCCCC,bold:true}}, 12 ];
3.效果