Hi,
I'm having trouble. The script below enables the
user to input a word, then click a button which will search a scrollable text field and then highlight the occurrence of the word that the user typed in. What I need it to do is, if this word is on a part of the text field
that is not visible, I need it to automatically scroll up or down to make the highlighted word visible. As someone suggested, it seems that I should use scrollByLine or scrollTop. However, I'm having trouble figuring out the conditions. How do I note which part of the text field is currently visible? Can anyone
steer me in the right direction? Thanks.
manfishj
on mouseUp
wordSearch = member ("searchWord".text
pMemRef = sprite (4).member
tempStr = member("pMemRef".text
hiliteList = []
counter = 0
repeat while offset (wordSearch, tempStr)
startChar = offset (wordSearch, tempStr)
endChar = startChar + wordSearch.char.count - 1
hiliteList.append ([counter + startChar, counter + endChar])
delete char 1 to endChar of tempStr
counter = counter + endChar
end repeat
pMemRef.color = color (#rgb, 0, 0, 0)
repeat with i in hiliteList
pMemRef.char[i[1]..i[2]].color = color (#rgb, 255, 0, 0)
end repeat
end
I'm having trouble. The script below enables the
user to input a word, then click a button which will search a scrollable text field and then highlight the occurrence of the word that the user typed in. What I need it to do is, if this word is on a part of the text field
that is not visible, I need it to automatically scroll up or down to make the highlighted word visible. As someone suggested, it seems that I should use scrollByLine or scrollTop. However, I'm having trouble figuring out the conditions. How do I note which part of the text field is currently visible? Can anyone
steer me in the right direction? Thanks.
manfishj
on mouseUp
wordSearch = member ("searchWord".text
pMemRef = sprite (4).member
tempStr = member("pMemRef".text
hiliteList = []
counter = 0
repeat while offset (wordSearch, tempStr)
startChar = offset (wordSearch, tempStr)
endChar = startChar + wordSearch.char.count - 1
hiliteList.append ([counter + startChar, counter + endChar])
delete char 1 to endChar of tempStr
counter = counter + endChar
end repeat
pMemRef.color = color (#rgb, 0, 0, 0)
repeat with i in hiliteList
pMemRef.char[i[1]..i[2]].color = color (#rgb, 255, 0, 0)
end repeat
end