Hi,
So, I have this little job to run some events from rolling over http links in a textfield. Clicking is no big deal.
Anyway, I came up with this method, using the rectangles derived from getCharBoundaries to basically calculate a hitrect for each word.
var wordRect:Array = []
var tmpString:String = introTxt.text
var strAr:Array = ["River Road", "Waikato River", "Hamilton City","Ngaruawahia"]
var startRect:Rectangle
var endRect:Rectangle
for (var i:String in strAr) {
startRect = introTxt.getCharBoundaries(tmpString.search(strAr*))
endRect = introTxt.getCharBoundaries(tmpString.search(strAr*) + strAr*.length)
wordRectArray.push([startRect.union(endRect),strAr*] )
}
trace(wordRectArray)
At the moment, it just pushes the rect and string in question into an array. I’m just gonna write a class that I’ll use instead of the array, which will handle dispatching back an event with the word and link’s url.
I dunno, is this the best approach to this problem. Am I missing something blindingly obvious about simulating rollOver events from text links?