Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-15-2008, 06:33 PM   #1
kpsony
Registered User
 
Join Date: May 2007
Posts: 7
Exclamation Click to clear text field

I am pretty new to AS3, and am trying to have my text field clear when I click it, then, if nothing is typed, go back to the original text. For example, I am using this for a "First Name" field.

This is the code I have that isnt working... thoughts? Its giving me an error for the focusHandler, but I cant find the right replacement property?

Code:
txName.focusHandler = function(){
	if(txName.text == "Full Name"){
		txName.text = "";
	}
}
txName.killFocusHandler = function(){
    if(txName.text == "")
    {
        txName.text = "Full Name";
    }
}

thank you!
kpsony is offline   Reply With Quote
Old 12-15-2008, 06:38 PM   #2
lordofduct
Senior Member
 
lordofduct's Avatar
 
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872
Default

Are you using AS3? There is no property of TextField called focusHandler or killFocusHandler.

you should be using the FocusEvent.FOCUS_IN and FocusEvent.FOCUS_OUT.

ActionScript Code:
myTextField.addEventListener( FocusEvent.FOCUS_IN, clearText ); myTextField.addEventListener( FocusEvent.FOCUS_OUT, checkText ); function clearText(e:FocusEvent):void {     myTextField.text = ""; } function checkText(e:FocusEvent):void {     if (myTextField.text == "")     {          myTextField.text = "Full Name";     } }
__________________
www.lordofduct.com - come read my blog!

If you want to know how to program, take a math class, take a lot of math classes!
lordofduct is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
bizarre input text field problem r€nato ActionScript 2.0 4 11-07-2008 03:05 PM
How do you something like this ... newttyy HTML and JavaScript 1 10-15-2007 09:02 PM
Select all text when user clicks input field. Jooma ActionScript 2.0 0 08-30-2007 06:06 PM
calling a PDF file in Flash AudryLucy Projectors and CDs 20 12-30-2006 01:43 PM
email form help nikmark Simple Stuff (Newbies) 17 06-14-2006 12:01 AM


All times are GMT. The time now is 03:54 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.