Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : formatting input text dynamically


xs_jenny
3/18/2004 11:32:05 PM
I'm trying to figure out how to format input text dynamically. I want the font
in an input text field to change in point size and become bold once an user has
typed a certain number of characters (200) into that field.

I've put the following actionscript on my input text movie clip (instance -
myText), but so far it's not working properly. Any advice?

onClipEvent (load) {
var typed;
typed = 0;
clicked = false;
myformat = new TextFormat();
myformat.bold = true;
myformat.size = 18;
}

onClipEvent (mouseDown) {
clicked = true;
}

onClipEvent (keyDown) {
if (clicked=true) {
typed += 1;
trace(typed);
}
if (typed ==200){
myText.setTextFormat(myformat);
}
}
djrez3
3/19/2004 2:56:24 AM
why don't you make a monitor MC that checks inputtext.length and when it hits
200 set a style format setting it to bold

like monitorMC

frame 1:
myTextFormat = new TextFormat();
myTextFormat.bold = true;

frame 2:
if(_root.inputtext.length > 200){
_root.inputtext.setTextFormat(myTextFormat);
}

frame3 :
gotoAndPlay(2);



it's kinda dirty but it works
pazzoboy
3/19/2004 3:33:19 AM
Common error #1 is to forget that second = in an 'if' statement. Here, typed will never increment....

onClipEvent (keyDown) {
if (clicked=true) {
typed += 1;
trace(typed);
}
xs_jenny
3/20/2004 8:02:51 PM
djrez3
9/8/2004 4:20:23 AM
AddThis Social Bookmark Button