Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » Flash - ActionScript

Change text color when typing begins (k)

 
Jump to:  
 
W. Kirk Lutz
PostPosted: Tue Aug 05, 2008 3:46 pm    Post subject: Change text color when typing begins (k)
       
Is there a way in a dynamic text field that when typing begins the text
in it changes to a certain color?

I have an if statement that writes a warning in the field if a user has
entered a negative number. It tells the user that numbers must be
positive and displays this message in red.

I want when the person begins to type over this warning for the text to
go back to black.

-Kirk
 

 
W. Kirk Lutz
PostPosted: Tue Aug 05, 2008 4:22 pm    Post subject: Re: Change text color when typing begins (k)
       
Also is there a way that when a user places their cursor in the field it
highlights everything in it? So that when they return to the field with
the warning to re-enter their number, they can just start typing and the
text will be black and the warning will be gone?

-kirk




W. Kirk Lutz wrote:
Quote:
Is there a way in a dynamic text field that when typing begins the text
in it changes to a certain color?

I have an if statement that writes a warning in the field if a user has
entered a negative number. It tells the user that numbers must be
positive and displays this message in red.

I want when the person begins to type over this warning for the text to
go back to black.

-Kirk
 

 
W. Kirk Lutz
PostPosted: Tue Aug 05, 2008 6:32 pm    Post subject: Re: Change text color when typing begins (k)
       
You're going to need to dumb this down to me. I am self taught in
ActionScript so I'm not well versed in terms like Selection class and such.

-kirk



kglad wrote:
> yes, check the Selection class to select text and you can use setTextFormat() and the textformat class to control font color.
 

 
kglad
PostPosted: Tue Aug 05, 2008 7:23 pm    Post subject: Re: Change text color when typing begins (k)
       
yes, check the Selection class to select text and you can use setTextFormat() and the textformat class to control font color.
 

 
W. Kirk Lutz
PostPosted: Tue Aug 05, 2008 7:33 pm    Post subject: Re: Change text color when typing begins (k)
       
Woohoo!

It worked. Now I just need to put it on the other two fields and this
puppy is done.

Thanks,
-kirk



kglad wrote:
Quote:
if tf is your textfield instance name, you can use:



var tfor:TextFormat=new TextFormat();
tfor.color = 0x000000;

var tl:MovieClip = this;
tf.onSetFocus = function(of) {
tl.onMouseUp=selectF;
};

function selectF(){
tl.onMouseUp=null;
Selection.setFocus(tf);
Selection.setSelection(0,tf.text.length);
tf.setNewTextFormat(tfor);
}
 

 
W. Kirk Lutz
PostPosted: Tue Aug 05, 2008 7:43 pm    Post subject: Re: Change text color when typing begins (k)
       
Works for one, but not for all.

When I put it in for each it always wants to select the last field.
There are three fields. Each needs this functionality.

I think it has to do with the onMouseUp part. The mouse button goes up
an it selects the last of the three commands.

The text fields are setup as Input Text, not MovieClips.

-Kirk





W. Kirk Lutz wrote:
Quote:
Woohoo!

It worked. Now I just need to put it on the other two fields and this
puppy is done.

Thanks,
-kirk



kglad wrote:
if tf is your textfield instance name, you can use:



var tfor:TextFormat=new TextFormat();
tfor.color = 0x000000;

var tl:MovieClip = this;
tf.onSetFocus = function(of) {
tl.onMouseUp=selectF;
};

function selectF(){
tl.onMouseUp=null;
Selection.setFocus(tf);
Selection.setSelection(0,tf.text.length);
tf.setNewTextFormat(tfor);
}
 

 
kglad
PostPosted: Tue Aug 05, 2008 9:05 pm    Post subject: Re: Change text color when typing begins (k)
       
if tf is your textfield instance name, you can use:



var tfor:TextFormat=new TextFormat();
tfor.color = 0x000000;

var tl:MovieClip = this;
tf.onSetFocus = function(of) {
tl.onMouseUp=selectF;
};

function selectF(){
tl.onMouseUp=null;
Selection.setFocus(tf);
Selection.setSelection(0,tf.text.length);
tf.setNewTextFormat(tfor);
}
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

gratka Angielski Boksy reklamowe Oferty pracy za granicÄ… Kochanowski Jan wiersze