问题:动态文本框旋转后消失的解决方法? 舞台上有一个实例名为btn 的按钮。代码层第一个关键帧上有如下语句:
_root.createTextFiled("dy_txt",999,100,100,90,50); with(dy_txt){ border=true; borderColor=0xff3388; background=true; backgroundColor=0x111111; type="dynamic" text="我要旋转" } btn.onRelease=function(){ dy_txt._rotation+=10; }
我想通过点击按钮实现动态文本框的旋转。但是当点击按钮后,动态文本框消失了。不知为什么? 请 高手指点一二。源文件如下: 旋转动态文本.rar
ywxgood解答:解决旋转文本消失的问题,有两种方法: 1、使用嵌入字体、即:将embedFonts属性设置为true,具体操作可以参看flash软件自带的帮助。 2、将文本框转换为位图,即:用BitmapData类处理。
代码如下:
///////////////////////////////////////////////////////////////////////// import flash.display.BitmapData; import flash.geom.Matrix; import flash.geom.ColorTransform; import flash.geom.Rectangle;
_root.createTextField("dy_txt", 1, 100, 200, 100, 22);
with (dy_txt) { border = true; borderColor = 0xff3388; background = true; backgroundColor = 0xff0000; type = "dynamic"; text = "Hello"; textColor = 0x000000; }
btn.onRelease = function() { _mc._rotation += 10; };
//创建宽度和高度跟文本框一样的BitmapData var bp:BitmapData = new BitmapData(dy_txt._width, dy_txt._height, false);
//显示位图,BitmapData类的draw方法帮助文档有详细介绍的 this.createEmptyMovieClip("_mc", 2); bp.draw(dy_txt, new Matrix(), new ColorTransform(), normal, new Rectangle(0, 0, dy_txt._width, dy_txt._height), true);
//如果不处理旋转是的锯齿,可以直接用下面一句,省去导入的ColorTransform,Matrix,Rectangle类. //bp.draw(dy_txt);
_mc.attachBitmap(bp, 1);
//隐藏原始文本框,设置位图剪辑的位置 _mc._x = dy_txt._x; _mc._y = dy_txt._y; dy_txt._visible = false;
/////////////////////////////////////////////////////////////////////////
源文件如下: 旋转文本.rar |