Groups | Blog | Home
all groups > flash (macromedia) > may 2007 >

flash (macromedia) : dynamic text size change


relief8
5/21/2007 9:55:57 PM
I have 2 text fields. 1 that the user types in and 1 that displays the text.
I want the displayed text to change size depending on how many letters the user
enters into the 1st text field. Any idea how to do this? Sample script posted
would be great. I have trouble opening .fla files from this forum for some
reason.
RTalisman
5/22/2007 5:27:16 AM
relief8,

Okay this should take you about a minute to create in Flash based on what I am
giving you...

Do the following:

Layer 1...
1. Create a Input Text instance name "myinput"
2. Create a Dynamic Text instance name "mytextfield"
3. Layer 1 has two frames (1 and 2, with Keyframe on 1 only).

Layer 2...
4. Frame 2 is a Keyframe. Code on Keyframe2: gotoAndPlay(1)

Back to Layer 1...
on Keyframe1, place the following
Code:
mysize = myinput.length * 4
mywords = myinput.text
mytextfield.html = true;
mytextfield.htmlText = "<font size=\"" + mysize + "\">" + mywords +
"</font>";

Run it.
The more you type, the bigger the font gets. Number of chars times four, to be
exact. You can of course edit the code to do what you need. This should be
enough to help you out. If not, Private Message me your email address and I can
email the .fla file I made up to check my script.

Hope all goes well.

Cheers

Rangar
AddThis Social Bookmark Button