Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Manipulate input text size to two different sizes in one field

Posted on 2011-03-16
9
Medium Priority
?
493 Views
Last Modified: 2013-11-11
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?
0
Comment
Question by:pixystk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 10

Expert Comment

by:Carnou
ID: 35151218
If you set the .htmlText member of the text field instead of the .text member, you can put an HTML string in there.  You should then be able to use regular html formatting.

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!
0
 

Expert Comment

by:BlakeRogers
ID: 35152422
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;

Open in new window

0
 

Author Comment

by:pixystk
ID: 35157732
@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
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Expert Comment

by:BlakeRogers
ID: 35157827
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.
0
 

Author Comment

by:pixystk
ID: 35157980
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.
0
 

Expert Comment

by:BlakeRogers
ID: 35158446
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.

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);

Open in new window


~Blake
http://www.onyxtekwebdesign.com
0
 

Expert Comment

by:BlakeRogers
ID: 35158462
The above would allow you to change the size independently, but mash them together for like a texfield output.
0
 
LVL 10

Accepted Solution

by:
Carnou earned 2000 total points
ID: 35160180
Sorry it took me so long to respond... personal issues kept me away from my computer till now.

Your fla has close to what you need.  The problem is that you set AltValA and B to be Numbers instead of Strings.
I'm including a version that works.  Once you click in the text field and modify the field, you'll see the results.

Just be careful of which variable is of what type, and the text manipulation becomes easy.

Let me know if you have any questions.
inputTextTest.fla
0
 

Author Closing Comment

by:pixystk
ID: 35160374
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!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

604 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