Groups | Blog | Home
all groups > flash (macromedia) > june 2005 >

flash (macromedia) : loc x and y of letter in string



mygraneboy
6/1/2005 10:22:50 PM
is it possible to find the x and y screen coordinates of letter in a text field

there is a way to do this in director, i am trying to get a movieclip to
proceed letters as they are typed, creating a flashing input style cursor
similar to most editing text editors, i am using a dynamic field and not an
input text box and lose the systems version of the cursor
NSurveyor
6/1/2005 10:33:09 PM
mygraneboy
6/1/2005 10:41:19 PM
basically it is a typing simulator, the user can tap away onthe keyboard
hitting any key and ala actionscript it appears on the screen. the text that
appears on the screen is placed one letter at a time (after each key down) and
read from an external text file which naturally contains coherent copy. i am
trying to keep a flashing cursor in front of the last letter of text typed at
all times, the type of field prohibits this cursor so i made one as a movieclip
i just need to move it along with the keystrokes
NSurveyor
6/1/2005 10:48:24 PM
Use the | character. Just use a variable to hold the current text. Then use a
loop with setInterval to show a | and then get rid of it on the next loop. This
should be pretty close to the effect. If you need help with this or do not
understand, I can help you in about an hour and a half. Sorry if my post seems
rushed, I'm running late...
mygraneboy
6/1/2005 11:09:33 PM
NSurveyor
6/1/2005 11:56:10 PM
NSurveyor
6/2/2005 1:01:04 AM
Try this code, just fill out the info in the Settings section:

//:Settings:
filepath = 'myfile.txt';
simfield = _root.tbox;
blinkRate = 250;
//:Load file:
lv = new LoadVars();
lv.onData = function(raw){
alltext = raw;
}
lv.load(filepath);
//:Simulate:
c = 0;
simtext = '';
listen = new Object();
listen.onKeyDown = function(){
if(alltext!=undefined){
simtext += alltext.charAt(c++);
}
}
Key.addListener(listen);
//:Update TextField:
t = 0;
setInterval(updateIt,10);
function updateIt(){
if(t){
simfield.text = simtext+'|';
}else{
simfield.text = simtext;
}
updateAfterEvent();
}
//:Blink Effect:
setInterval(blinkIt,blinkRate);
function blinkIt(){
t = (t+1) % 2
}
mygraneboy
6/2/2005 2:10:13 PM
mygraneboy
6/3/2005 4:02:21 PM
thanks again for the code, I actully got it working, with only one problem ,
when the file runs it leaves a trail of the flashing character, that does not
get erased as you advance through the file, any thoughts?
AddThis Social Bookmark Button