Solved

How can I clear field on focus, AS2

Posted on 2011-09-02
10
495 Views
Last Modified: 2012-05-12
How can I clear a field on focus in action script 2 ??

TIA
experts.
0
Comment
Question by:Imaginx
  • 5
  • 5
10 Comments
 
LVL 29

Expert Comment

by:dgofman
ID: 36478335
Here si my example:

var tf1:TextField = createNewTextField();
var tf2:TextField = createNewTextField();
tf1._x = 10;
tf2._x = tf1._x + tf1._width + 10;

function createNewTextField():TextField{
	var depth:Number = _root.getNextHighestDepth();
	var tf:TextField = _root.createTextField("textfield" + depth, depth, 0, 0, 200, 25);
	tf.border = true;
	tf.type = "input";
	tf.text = "1234567890";
	tf.onSetFocus = function() {
		this.text = "0987654321";
	};
	tf.onKillFocus = function() {
		this.text = "";
	};
	return tf;
}

Open in new window

0
 
LVL 1

Author Comment

by:Imaginx
ID: 36481384
I have two fields already.
_root.qk_name & _root.qk_phone

Same fla as the previous question.

How/Where should I implement the code above.

qk_name should be variable character.
qk_phone is displayed "Phone: ###-###-####", but a user should only be able to input numbers & dashes
0
 
LVL 29

Expert Comment

by:dgofman
ID: 36481504
can you upload your fla?

if you have created movieclip instance you should able to use my functions:

_root.qk_name.tf.onSetFocus = function() {
            this.text = "";
      };
_root.qk_name.onKillFocus = function() {
            this.text = "###-###-####";
      };
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:Imaginx
ID: 36552318
dgofman,

I was out of town for a while, never got online to ee.

What happened to the other question you worked with me on?
Did the mods get you the points after all ??
If not, let me know so I can email someone & try to get it fixed.

-steve

here's the download link to the fla file
files.me.com/swaskey/cjow20

EE won't let me attach it, keeps saying:
"The extension of one or more files in the archive is not in the list of allowed extensions: bin/SymDepend.cache" ... It's just a normal fla file, 880kb ..

Thanks.
0
 
LVL 29

Expert Comment

by:dgofman
ID: 36552606
Save your file as CS4 and you will able to upload to EE
0
 
LVL 1

Author Comment

by:Imaginx
ID: 36552617
That worked.
Here's the file.
Thx.

premiere-2-cs4.fla
0
 
LVL 29

Accepted Solution

by:
dgofman earned 500 total points
ID: 36552882
Ok,
Here is my changes I also added validation premiere-2-cs4.fla
0
 
LVL 1

Author Comment

by:Imaginx
ID: 36552897
Thanks Dgofman,
This is what I get when I export the swf, the onfocus clears the name perfectly, but the number field only permits numbers 1,8,5,9 (which I think it may have already done for some reason) and once I type in anything - the Phone field just goes right back to Phone: ###-###-####

What's causes that?
0
 
LVL 29

Expert Comment

by:dgofman
ID: 36552907
Because I am validation only number by your mask ###-###-####

111-222-3333
444-555-6666
ect.
If number is not matched I reset to old text.
Look on my login in the first frame
0
 
LVL 1

Author Comment

by:Imaginx
ID: 36552931
I see, I understand the code as well - nice & simple .. Thanks !!

I'll post another question about only the numbers 1,5,8,9 showing up.

Here's the question ID: 27313172

Thanks again.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can not play videos on sciencechannel.com in Chrome 13 131
Contact Forms for Website 6 82
Getting attribute Values using xslt 4 47
Facebook React and SyntheticEvents 6 67
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question