Thanks Juan..
That is much cleaner.
Thank you also for the AS3 conversion.
That helps me understand just a little more about AS3.
Best,
Karl
On Jun 15, 2010, at 9:56 PM, Juan Pablo Califano wrote:
It seems like you don't really need to bother about gaining or
losing focus
here. Just listening to the change event will do the job and you could
remove the enter_frame.
commentxt_mc.onChanged = function(tf:TextField):Void {
var numChar:Number = 650 - tf.length;
if (numChar == 0) {
maxChar = "Max Characters Reached";
} else {
maxChar = "Max Char: " + numChar.toString(); //Have
another
text box with the var maxChar to display the results while typing.
}
};
The equivalent in AS 3.0 is very similar, though a bit more verbose
(as
usual!):
commentxt_mc.addEventListener(Event.CHANGE,handleTextChange);
function handleTextChange(e:Event):void {
var tf:TextField = e.target as TextField;
if(!tf) {
return;
}
var numChar:Number = 650 - tf.length;
var maxChar:String = "";
if (numChar == 0) {
maxChar = "Max Characters Reached";
} else {
maxChar = "Max Char: " + numChar.toString(); //Have another text
box with
the var maxChar to display the results while typing.
}
}
Cheers
Juan Pablo Califano
2010/6/15 Karl DeSaulniers <k...@designdrumm.com>
PERFECTO!
Thanks Amol,
For anyone who might want this. I have made a script that will
read the
length of a text field and display the number of characters left
while
someone was typing.
The reason for the code I was seeking with this request was
because the
code previously would eat up a lot of memory. It made my computer
fan run
wild if the form sat in my browser.
Now it does not thanks to Amol. :))
Here is the code competed. Again, it is as2, but would love to see
an as3
conversion.
I might get to that later, but welcome any comers.
//commentxt_mc is the textfield name, 650 is the number of characters
allowed. You will also want to set the text box max characters to
this when
creating your text box.
var numChar;
commentxt_mc.onSetFocus = function() {
onEnterFrame = function() {
numChar = 650 - commentxt_mc.length;
if (numChar == 0) {
maxChar = "Max Characters Reached";
} else {
maxChar = "Max Char: " + numChar.toString(); //Have
another
text box with the var maxChar to display the results while typing.
}
}
};
commentxt_mc.onKillFocus = function() {
onEnterFrame = null;
};
Best,
Karl
On Jun 15, 2010, at 1:34 AM, Amol wrote:
Hi,
use set fouse for text ,
sample_txt.onSetFocus = sample1_txt.onSetFocus = function ()
{
this.border = true;
this.borderColor = 13683368;
this.background = true;
this.backgroundColor = 13683368;
};
sample_txt.onKillFocus = sample1_txt.onKillFocus = function ()
{
this.border = true;
this.borderColor = 0;
this.background = true;
this.backgroundColor = 0;
};
Regards amol
----- Original Message ----- From: "Karl DeSaulniers" <
k...@designdrumm.com>
To: "Flash List" <flashcoders@chattyfig.figleaf.com>
Sent: Tuesday, June 15, 2010 9:51 AM
Subject: [Flashcoders] Text area focus
Hello,
I have a text box or area on a form that I would like to know
when a
user has put the cursor in it or not.
Wither it has focus or not. I am working in AS2. Please don't
grit your
teeth too much :-)
For some reason I am not able to get the focus of my text area.
Anyone have this code in their scrap files?.. lol
TIA
Karl DeSaulniers
Design Drumm
http://designdrumm.com
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Karl DeSaulniers
Design Drumm
http://designdrumm.com
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Karl DeSaulniers
Design Drumm
http://designdrumm.com
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders