2011-01-10 121 views
0

alt text一半的信是一种颜色,另一半另一种颜色

我想知道是否有可能有一个是由多种颜色的信。例如上面你会看到一封希伯来文字母。它下面的DOT实际上是字母的一部分,但它是一种不同的颜色。

是否有可能在Flash中具有相同的功能?我需要做的就是上传一个包含所有单词的XML文件,并且我需要将字母下方的所有点用作不同的颜色。

信来自这个网站:

http://www.oryanit.com/site/2.1.asp?user=oryanit&site=56

回答

1

你不能用动态的TextField恐怕这样做在Flash。

+0

@heartcode我能做到这一点它 – 2011-01-10 17:24:00

+0

@herrow随着一些矢量图形的技巧,你可以做到这一点! – bzlm 2011-01-10 17:29:29

0

这里是一个基本的例子:

import flash.text.TextField; 
import flash.text.TextFormat; 
import flash.display.BitmapData; 
import flash.display.Bitmap; 
import flash.geom.Rectangle; 
import flash.geom.Point; 

/* 
* This is your character 
*/ 
var tf:TextField = new TextField(); 
tf.selectable = false; 
tf.text = "B"; 
addChild(tf); 
var fmt:TextFormat = new TextFormat(); 
fmt.size = 50; 
tf.setTextFormat(fmt); 

//Creating a bitmapData from the TextField 
var tfBD:BitmapData = new BitmapData(tf.textWidth, tf.textHeight); 
tfBD.draw(tf); 
var tfB:Bitmap = new Bitmap(tfBD); 
addChild(tfB); 

//Creating the top part of the character 
var tfTopBD:BitmapData = new BitmapData(tfBD.width, tfBD.height/2); 
tfTopBD.copyPixels(tfBD, new Rectangle(0, 0, tfBD.width, tfBD.height/2), new Point(0, 0)); 
var tfTopB:Bitmap = new Bitmap(tfTopBD); 
addChild(tfTopB); 

//Creating the bottom part of the character 
var tfBottomBD:BitmapData = new BitmapData(tfBD.width, tfBD.height/2); 
tfBottomBD.copyPixels(tfBD, new Rectangle(0, tfBD.height/2, tfBD.width, tfBD.height/2), new Point(0, 0)); 
var tfBottomB:Bitmap = new Bitmap(tfBottomBD); 
addChild(tfBottomB); 


tfB.x = Math.round(stage.stageWidth/2 - tfB.width/2); 
tfB.y = Math.round(stage.stageHeight/2 - tfB.height/2); 
tf.x = tfB.x - 50; 
tf.y = tfB.y; 
tfTopB.x = tfB.x + 50; 
tfTopB.y = tfB.y; 
tfBottomB.x = tfB.x + 50; 
tfBottomB.y = tfB.y + tfTopB.height + 10; 

基本上我创建两个BitmapData对象和我文本框的内容复制到他们,所以我得到的顶部和字符的底部。然后,您可以根据需要重新着色。

对于AS3着色我会建议使用使用GreenSock补间引擎,哗哗我更喜欢使用colorMatrixes等丑陋的东西。 http://www.greensock.com/

希望它适合你, 罗布

相关问题