Hi Danny, it would be multi line text and I don't know if it will be center
aligned. Maybe some parts will be. I didn't really get the technique you
described. Can you please try and describe it again? Or is it possible that
you share the code that you have? I can even compensate it somehow if it
gets used.

Another idea is to sort of hardcode the y values, as textfield will always
be in the same place and always the same font size and font face (hopefuly).
X value of mouse press is simple and I would just see where in which row of
the grid the mouse press occured and use that. Say I know each row is 10 px
high, and the press occurs on x=56, y=23. I would then start drawing the
rectangle from the point 56,20.


Alen


> Hi list, any tips on how to create a text highlighter? The
perfect solution will be that I use the text cursor inside
the textfield. Now, I was thinking of using drawing API on
the invisible mc below the textfiled and when I would click
in the textfield I would start drawing a rectangle on that mc.
But, the problem is that with the text cursor you can click
anywhere between the lines and it will select the closest
line. So I can't get the exact y coordinate where to start
drawing the rectangle.

Also, I don't think I can use background-color css property
as it's not supported according to Flash documentation.

It's a very tricky problem - not only are there the problems you mention,
but also if they're selecting multiple lines you need to draw three
rectangles rather than one - the shorter top and bottom part-lines and the
full lines in the middle.

I've done it in the past (although in the end I didn't use it) by creating a
function that homes in on the exact coordinates of the insertion point by
adding text into a hidden field and using textWidth / textHeight (the tricky
part is finding the start of the current line, the rest is fairly easy,
although I'm not sure how you'd do centre-aligned text). It sounds hideous,
but actually Flash is pretty fast at that kind of thing and it worked fine
in real-time for reasonably short text. If your text is single-line,
obviously it's much easier.

Best
Danny
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to