Not really. In theory, onChanged should be less intensive, I think. But,
from your description it seems it isn't, so go figure...

I'd go with the onSetFocus / onKillFocus then, but I'd do another test, just
out of curiosity. Instead of setting an enterframe when you get focus and
nulling it when focus is lost, what happens is you use the onChanged event
instead?

I mean, something like:

textbox.onSetFocus = function() {
   textbox.onChanged = etc...;
};
textbox.onKillFocus = function() {
   textbox.onChanged = null;
}
Cheers
Juan Pablo Califano

2010/6/16 Karl DeSaulniers <[email protected]>

> Hi Juan,
> Interesting enough, it seems your solution also runs my fan a bit wild too.
> Not as bad, I'd say about half as much.
> I know its the form because I have tested many times. Every time I close
> the browser window that has the form, my fan slows to a stop almost
> immediately.
> I chose the onFocus mainly because I knew that it was the onEnterFrame that
> was taking up memory, so I wanted it to fire only when someone was typing.
> It looks like my suggestion does just that. The fan never kicks on.
>
> My purpose for this is to set up a flash site that takes little to no
> memory usage.
> Am I right in assuming that this is memory usage by the code that makes my
> fan kick in.
> I've been nulling any onEnterFrames, removing listeners, etc.
> Any thoughts as to why the onChanged eats memory too?
> TIA
>
> 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 <[email protected]>
>>
>> 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" <
>>>> [email protected]>
>>>> To: "Flash List" <[email protected]>
>>>> 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
>>>>> [email protected]
>>>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>>>
>>>>>  _______________________________________________
>>>>>
>>>> Flashcoders mailing list
>>>> [email protected]
>>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>>
>>>>
>>> Karl DeSaulniers
>>> Design Drumm
>>> http://designdrumm.com
>>>
>>> _______________________________________________
>>> Flashcoders mailing list
>>> [email protected]
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to