pixystk
asked on
Manipulate input text size to two different sizes in one field
Hi there,
I have an input text field with an CHANGE event listener. As the user enters text I'd like to modify the display of the text so that if they enter 25000, 25 is larger than 000.
So far I've only been able to use a substr on the field and trace the output.
Is this possible?
I have an input text field with an CHANGE event listener. As the user enters text I'd like to modify the display of the text so that if they enter 25000, 25 is larger than 000.
So far I've only been able to use a substr on the field and trace the output.
Is this possible?
Basically you just need to use the autoSize on a text field in actionscript if I understand your problem correctly.
Var myText:TextField = new TextField();
myText.autoSize = TextFieldAutoSize.LEFT;
ASKER
@Carnou - I like the idea of using htmlText, but now I'm running into an issue with my substr... it keeps throwing errors (coercion and undefined method substr). Can you take a look and see what I'm doing wrong?
And... @BlakeRogers - what does AutoSize do? I don't understand how that would work being that it doesn't necessarily know which characters to apply the size to.
inputTextTest.zip
And... @BlakeRogers - what does AutoSize do? I don't understand how that would work being that it doesn't necessarily know which characters to apply the size to.
inputTextTest.zip
Is there a definite number of characters that will have a different size every time?
For instance the string "Happy" has 5 characters and even if the string grows we want the first 2 characters "HA" to be in a bigger font.
For instance the string "Happy" has 5 characters and even if the string grows we want the first 2 characters "HA" to be in a bigger font.
ASKER
Yes...
if there are 5 chars then the first two will be larger than the last three.
25 big 000 small. If there are four chars, then for 2500 the 2 is big and the 500 is small.
if there are only three chars, then all three are small.
if there are 5 chars then the first two will be larger than the last three.
25 big 000 small. If there are four chars, then for 2500 the 2 is big and the 500 is small.
if there are only three chars, then all three are small.
This is the best way that I know to do this... You should be able to cut and past this into an actions layer of an fla. After this you would just need to concat the strings. Let me know if you need help with that.
~Blake
http://www.onyxtekwebdesign.com
var str:String = "Happy Monday";
//trace(str.slice(0,5));
/*do the above to make sure that you get the amount you want. Don't forget double index*/
var strModify:String = str.slice(0,5);
var strLeftOvers:String = str.slice(6, str.length);
//trace(strModify);
//trace(strLeftOvers);
~Blake
http://www.onyxtekwebdesign.com
The above would allow you to change the size independently, but mash them together for like a texfield output.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!
I was going in circles swapping out variables trying to find what was wrong. Thanks for taking a look at that and thanks for the htmlText solution, it's exactly what I wanted!
I was going in circles swapping out variables trying to find what was wrong. Thanks for taking a look at that and thanks for the htmlText solution, it's exactly what I wanted!
A simple example:
textfield.htmlText = "<font size='10'>25</font><font size='4'>000</font>";
Of course, if you're making substrings, just add those in:
textfield.htmlText = "<font size='10'>" + sub_string_1 + "</font><font size='4'>" + sub_string_2 + "</font>";
You can use this to set color, font size, or just about anything else. Hope this helps!