我在Flash中有一個文本字段,其中包含一個(明顯)文本塊。AS3:獲取文本字段中匹配字符串的x和y值
我想要做的是對文本字段的內容進行搜索,該文本字段返回找到的文本的x & y
coordiante和width & height
。結果將用於在文本框的該部分上放置可視元素。
例如:
var pattern:RegExp = /\d+/g;
var found:Array = box.text.match(pattern);
var i:String;
for each(i in found)
{
/**
* Find the x, y, width, height of the matched text in the text field
* Use result to place transparent yellow box around text
*/
}
在視覺上應該導致這樣的:
有趣的問題,我總是想知道如何做到這一點! –