2012-01-06 34 views
0

我正在將一個textfield繪製到我用作3D對象紋理的位圖上。 我正在偵聽Event.change,所以無論何時用戶添加一個字符,我都會重繪紋理。但爲了真正爲3D對象提供'交互式文本字段的感覺',我想繪製文本選擇並繪製插入符號(閃爍的文本光標),但默認情況下,這些字符在使用bitmapData.draw(textField)時不會繪製,也不能找到一個事件來偵聽'textSelected'。將textfield caret和文本選擇繪製到位圖

任何想法?

//is there any event that catches text selection/blinking of text-cursor? 
textField.addEventListener(Event.CHANGE, redrawTexture); 
//... 
//is there any way to draw text selection/text-cursor in the bitmap? 
bmpData.draw(textField); 

回答

0
textField.addEventListener(FocusEvent.FOCUS_IN, redrawTexture, false, 0, true); 

textField.addEventListener(FocusEvent.FOCUS_OUT, redrawTexture, false, 0, true); 

var bmp:BitmapData = new BitmapData(width, height); 
bmp.draw(textField); 
var snapshot:Bitmap = new Bitmap(bmp);