Think it's a dead end though. Due to the varying widths of letters within a font, it's seems to be impossible to accurately convert the caret point number to spacial coordinates.
Check McUshers code in the other thread ... I think it works, yet it's a work around... Yes, I agree there is not a direct method for achieving what you want.
while (2+2 == 4) {
drink ("bourbon");
}
gotoAndStop("bed");
To make this thread more complete (i have the hope, that somebody
will ever use the search button) i post the idea here as well..
Remember it is only a proof of concept, it is still unprecise and need some
tweaking..
I think the order of the letters in the checkTxtX field for the x-coordinate has to
be reversed. Maybe i you don't wanna do it, i have a deeper look into it...
either of who finish the script should post it in the OpenFla section.
[fla removed, see next post]
Last edited by McUsher; 11-23-2005 at 08:48 PM.
My letters on the F1 key have faded, how are yours today?
I was too curious and had a further look,
it turned out, that the property "textWidth" was too unprecise
on a text in stage, i had to create the "X-Check" text dynamically..
Here is the new Fla,
Which is very precise now, but lacks some linebreak issues..
(and i am not sure if i really fixed that infinite loop i was
running into with the two while() loops)
Fla should be MX2004
My letters on the F1 key have faded, how are yours today?
Just in case, someone ever finds this thread, here is a correction, that makes the calculation very precise, there might be errors still in it though.
AS1, FP6:
PHP Code:
var iT = inputTextField;
iT.text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque vel quam. Aliquam lectus arcu, semper quis, consequat sit amet, tempor sit amet, enim. Ut mattis. Cras sit amet nunc et sem ornare suscipit. ";
var tmpHeight;
var tf = iT.getTextFormat();
this.onEnterFrame = function () {
// calculation y position of the caret.
var caretPos = Selection.getCaretIndex();
var nextSpace = iT.text.indexOf(" ",caretPos);
var indexForHeight = (nextSpace > -1) ? nextSpace : caretPos;
checkTxt.text = iT.text.substr(0, indexForHeight);
marker._y = iT._y+checkTxt.textHeight;
// calculation of the x position
tmpHeight = checkTxt.textHeight;
checkTxt.text = iT.text.substr(0, caretPos);