-
Designer, Programmer, Musician
[RESOLVED] A way of detecting typing in a textbox in realtime w/o using onEnterFrame
Hello guys ^_^
Before posting for help, i always do an exhaustive research on the web. \
This time, i need to know how to detect when typing in a textbox in realtime, without using onEnterFrame, as onEnterFrame use a lot of CPU. You type in an input textbox, and then show that in a dynamic textbox as you type.
I already have this
Actionscript Code:
stop();
var texto:String;
textobtn.onPress=function(){ if(texto!=""){ textoMC.texto=texto; gotoAndPlay(2);
} else { trace("textbox is empty"); } };
But it only shows when you press a button.
-
.
Hi,
you can do something simple like this perhaps.
Actionscript Code:
myTextField.onChanged = function(){ //your function here. }
-
Designer, Programmer, Musician
Hahaha! Just the script that i tested yesterday, but failed.
Actionscript Code:
texto.onChanged=function(){ textoMC.texto=texto; }
"There is no property with the name 'onChanged' "
-
.
Hi,
Here is a little example for you to test the onChanged property
Actionscript Code:
var total = 50;// Set amount myDynamic.text = "Remaining : " + total;// Dynamic textField myInput.text = "";// Input textField myInput.maxChars = total;// Restrict to same as total var myInput.onChanged = function(textField) { myDynamic.text = "Remaining : " + (total - myInput.text.length); // Show remaining number each time changed };
.
-
Designer, Programmer, Musician
Ok, i understand it well, but one thing, and thanks for everything.
I'm using variable name instead of instance name, because if i use instance name, the color of my input textbox is transferred (weirdly) to my dynamic textbox. I tried specifying my textboxes colors
Actionscript Code:
myInputTextbox.text.TextField.color="#FFFFFF";
myDynamicTextbox.text.TextField.color="#003366";
But failed. So i thought "mmm variable names?" and it worked. But the onChanged seems does not work with variable name...
-
Designer, Programmer, Musician
Okay! Done.
Actionscript Code:
stop();
texto.onChanged=function(){ textoMC.texto=texto.text; }
textoMC.texto.text=""
textobtn.onPress=function(){ if(texto.text!=""){ textoMC.texto=texto.text; gotoAndPlay(2); } else { trace("ok no hay nada"); } }
Used Instance Name again and it magically worked. Thanks
-
.
I see you managed it!!!
Dcolor = 0x333333;
Icolor = 0x800800;
myDynamicTextbox.textColor = Dcolor;
myInputTextbox.textColor = Icolor;
var total = 50;// Set amount
myDynamicTextbox.text = "Remaining : " + total;
myInputTextbox.text = "";
myInputTextbox.maxChars = total;
myInputTextbox.onChanged = function(textField)
{
myDynamicTextbox.text = "Remaining : " + (total - myInputTextbox.text.length);
myInputTextbox.textColor = Icolor;
myDynamicTextbox.textColor = Dcolor;
};
Last edited by fruitbeard; 07-16-2012 at 10:47 AM.
-
Designer, Programmer, Musician
Thanks for the color textbox function is really great and I will surely need it later
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|