actionscript3.0那个textformat的实例的属性比如color能不能动态改变? 高手帮忙!!!
展开全部
如果是想做成按钮那样,鼠标移上去就改变颜色的话是可以的。
代码如下:
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
/**
* ...
* @author sanny
*/
public class Main extends Sprite
{
private var tt:TextField;
private var tformat:TextFormat;
private var overFormat:TextFormat;
public function Main():void
{
tt = new TextField();
tt.text = "测试测试测试"
tformat = new TextFormat();
tformat.color = 0xFF0000;
//鼠标RollOver时颜色样式
overFormat = new TextFormat();
overFormat.color = 0x000000;
tt.setTextFormat(tformat)
addChild(tt);
tt.addEventListener(MouseEvent.MOUSE_OVER, overHandle);
tt.addEventListener(MouseEvent.MOUSE_OUT, outHandle);
}
private function overHandle(e:MouseEvent):void {
tt.setTextFormat(overFormat)
}
private function outHandle(e:MouseEvent):void {
tt.setTextFormat(tformat)
}
}
}
代码如下:
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
/**
* ...
* @author sanny
*/
public class Main extends Sprite
{
private var tt:TextField;
private var tformat:TextFormat;
private var overFormat:TextFormat;
public function Main():void
{
tt = new TextField();
tt.text = "测试测试测试"
tformat = new TextFormat();
tformat.color = 0xFF0000;
//鼠标RollOver时颜色样式
overFormat = new TextFormat();
overFormat.color = 0x000000;
tt.setTextFormat(tformat)
addChild(tt);
tt.addEventListener(MouseEvent.MOUSE_OVER, overHandle);
tt.addEventListener(MouseEvent.MOUSE_OUT, outHandle);
}
private function overHandle(e:MouseEvent):void {
tt.setTextFormat(overFormat)
}
private function outHandle(e:MouseEvent):void {
tt.setTextFormat(tformat)
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询