Moving AS3 Carat vertically
earlier struggling moving carat horizontally need move & down text field.
this virtual keyboard arrow controls done coded buttons.
heres example: have text field has 2 lines varrying amount of text, , our carat @ end of bottom line. goal move carat end of first line.
var boop = textselect.text.length;
var snoop = boop;
// arrow controls move left , right
function larw(event:mouseevent):void
{
snoop -= 1;
stage.focus = textselect;
textselect.setselection( snoop,snoop);
}
function rarw(event:mouseevent):void
{
snoop += 1;
stage.focus = textselect;
textselect.setselection( snoop,snoop);
}
// moving
function uarw(event:mouseevent):void
{
}
find position (using maxscrollv , loop) , use setselection again:
var index:int=indexf(your_tf,1); // find end of line 1 in your_tf. might want more massaging if don't want select white space.
your_tf.setselection(index,index)
// don't change function:
function indexf(tf:textfield,linenumber:int):int{
var h:int = tf.height;
tf.height = 5;
var s:string = tf.text;
tf.text = "";
//trace(tf.maxscrollv);
for(var i:int=0;i<s.length;i++){
if(tf.maxscrollv<=linenumber){
tf.appendtext(s.charat(i));
} else {
break;
}
}
tf.text = s;
tf.height = h;
return i-1;
}
More discussions in ActionScript 3
adobe
Comments
Post a Comment