|
|
|||||
Et cetera
Регистрация: Sep 2002
Сообщений: 30,784
|
У меня тоже не работает draw на текст.
|
|
|||||
странно, что сейчас у меня все рисует..
но в одном проекте был такой затык, решился через blendMode метода draw: bmp.draw(txt,new Matrix(),null,"layer",null,true); не все вполне ясно с этими текстфилдами.. |
|
|||||
Et cetera
Регистрация: Sep 2002
Сообщений: 30,784
|
Я за точность
import flash.geom.*; import flash.display.BitmapData; getTextBounds = function(txt) { var x = txt._x; var y = txt._y; var w = txt._width; var h = txt._height; var xs = txt._xscale; var ys = txt._yscale; var scale = 20; txt._xscale = xs*scale; txt._yscale = ys*scale; var bmp = new BitmapData(txt._width,txt._height,true,0); var mtx = new Matrix(); mtx.scale(scale,scale); bmp.draw(txt, mtx); bmp.colorTransform(bmp.rectangle,new ColorTransform(1,1,1,1,0,0,0,255)); var rect = bmp.getColorBoundsRect(0xFF000000,0x00000000, false); bmp.fillRect(rect,0x80FFFF00); rect.x /= scale; rect.y /= scale; rect.width /= scale; rect.height /= scale; txt._xscale = xs; txt._yscale = ys; bmp.dispose(); return rect; } rect = getTextBounds(txt); beginFill(0xFF0000, 30); trace(rect); moveTo(txt._x+rect.x+2,txt._y+rect.y+2); lineTo(txt._x+rect.x+rect.width+2,txt._y+rect.y+2); lineTo(txt._x+rect.x+rect.width+2,txt._y+rect.y+rect.height+2); lineTo(txt._x+rect.x+2,txt._y+rect.y+rect.height+2); endFill(); |
|
|||||
Цитата:
__________________
Тут вам не здесь!!! Последний раз редактировалось etc; 05.07.2007 в 19:24. |
|
|||||
Регистрация: Oct 2006
Адрес: spb.ru
Сообщений: 3,221
|
У меня рисует раз через пять, причем непонятно от чего зависит. Ставил input, dynamic, разные параметры сглаживания и разный размер шрифта. Не стоит отрисовывать битмапой тектовое поле, нет в это веры.
Стало быть... import flash.geom.*; import flash.display.BitmapData; function getSize (mc:MovieClip):Rectangle { var bmp:BitmapData = new BitmapData (Math.ceil(mc._width), Math.ceil(mc._height), true, 0); bmp.draw (mc); var rect:Rectangle = bmp.getColorBoundsRect(0xFF000000, 0x00000000,false); bmp.dispose(); drawBounds(mc, rect); return rect; } getTextBounds = function(txt) { var x = txt._x; var y = txt._y; var w = txt._width; var h = txt._height; var temp_mc:MovieClip = createEmptyMovieClip('temp_mc', getNextHighestDepth()); var temp_txt:TextField = temp_mc.createTextField('txt',1,0,0,w+5,h+5); temp_txt.embedFonts = txt.embedFonts; temp_txt.text = txt.text; temp_txt.setTextFormat(txt.getTextFormat()); var rect:Rectangle = getSize(temp_mc); // temp_mc.removeMovieClip(); rect.offset(x,y); return rect; } function drawBounds( mc:MovieClip, rect:Rectangle ){ mc.clear(); mc.beginFill(0xFF0000, 30); mc.moveTo(rect.left, rect.top); mc.lineTo(rect.left, rect.bottom); mc.lineTo(rect.right, rect.bottom); mc.lineTo(rect.right, rect.top); mc.lineTo(rect.left, rect.top); mc.endFill(); } rect = getTextBounds(txt); drawBounds(this, rect); trace(rect); Последний раз редактировалось Kikasso; 06.07.2007 в 05:11. |
|
|||||
Et cetera
Регистрация: Sep 2002
Сообщений: 30,784
|
import flash.geom.*; import flash.display.BitmapData; getTextBounds = function(txt) { var mc = txt._parent.createEmptyMovieClip('__textBounds_mc',-3288); var t = mc.createTextField('txt',0,0,0,100,100); t.setNewTextFormat(txt.getTextFormat()); t.embedFonts = txt.embedFonts; t.html = txt.html; t.htmlText = txt.htmlText; t._width = txt._width; t._height = txt._height; txt = t; var xs = txt._xscale; var ys = txt._yscale; var scale = 20; var maxXScale = 2800/txt._width; var maxYScale = 2800/txt._height; if (maxXScale < scale) { scale = maxXScale; } if (maxYScale < scale) { scale = maxYScale; } txt._xscale = xs*scale; txt._yscale = ys*scale; var bmp = new BitmapData(mc._width,mc._height,true,0); bmp.draw(mc); bmp.colorTransform(bmp.rectangle,new ColorTransform(1,1,1,1,0,0,0,255)); var rect = bmp.getColorBoundsRect(0xFF000000,0x00000000, false); bmp.fillRect(rect,0x80FFFF00); rect.x /= scale; rect.y /= scale; rect.width /= scale; rect.height /= scale; txt._xscale = xs; txt._yscale = ys; bmp.dispose(); mc.swapDepths(6550); mc.removeMovieClip(); return rect; } rect = getTextBounds(txt); beginFill(0xFF0000, 30); moveTo(txt._x+rect.x,txt._y+rect.y); lineTo(txt._x+rect.x+rect.width,txt._y+rect.y); lineTo(txt._x+rect.x+rect.width,txt._y+rect.y+rect.height); lineTo(txt._x+rect.x,txt._y+rect.y+rect.height); endFill(); |
Часовой пояс GMT +4, время: 16:27. |
|
« Предыдущая тема | Следующая тема » |
Опции темы | |
Опции просмотра | |
|
|