# Changin font size on the fly

**URL:** https://forum.kirupa.com/t/changin-font-size-on-the-fly/25658
**Category:** flash
**Created:** [July 15, 2003, 2:14pm UTC](https://forum.kirupa.com/t/changin-font-size-on-the-fly/25658 "2003-07-15T14:14:27Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jimboxl](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jimboxl](https://forum.kirupa.com/u/jimboxl)
#### Post date: [July 15, 2003, 2:14pm UTC](https://forum.kirupa.com/t/changin-font-size-on-the-fly/25658/1 "2003-07-15T14:14:27Z")

</div>

I was working on a way to allow users to change the font size for all the words by clicking a button in my flash movie so I’ve come up with this line:

on (press) {  
dropdownmov.var4 = font face=\Arial\ size=\12&gt; var4 /font;

}

I was trying to get the html formatting applied to var4 and then saved as dropdownmov.var4 to make the text size increase. I’ve been looking for a way to allow the user to increase the font size and so far this is the only idea I’m getting after looking everywhere trying to find some function and trying other functions as well. I know you can modify Flash UI component text size and what not with some commands, but I haven’t seen anything neat for applying changes to text boxes in realtime. I had to take out the quotations and the \<\> from the piece of code I gave to make the whole line display on the message board, so just ignore the absence.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 2:23pm UTC](https://forum.kirupa.com/t/changin-font-size-on-the-fly/25658/2 "2003-07-15T14:23:18Z")

</div>

What you need to do is pass var4 through to a new variable that is inline with your new HTML code. That is the only way that I can think about how to do it.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 2:27pm UTC](https://forum.kirupa.com/t/changin-font-size-on-the-fly/25658/3 "2003-07-15T14:27:43Z")

</div>

My problem is getting the text out of the variable because when I make that statement the value of dropdown.var4 literally becomes “var4” as in the text becomes var4 onscreen. I’m not sure how I’d pull out the text within var4 to make the HTML format changes to it in the line I gave.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 2:33pm UTC](https://forum.kirupa.com/t/changin-font-size-on-the-fly/25658/4 "2003-07-15T14:33:03Z")

</div>

Can you post an FLA?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 2:35pm UTC](https://forum.kirupa.com/t/changin-font-size-on-the-fly/25658/5 "2003-07-15T14:35:29Z")

</div>

You just want to increase the font size? Apply the following code on a button:[AS]on(press){  
myTextFormat = new TextFormat();  
myTextFormat.size = 20;//set new size  
myTextField.setTextFormat(myTextFormat);  
}[/AS]Replace myTextField with the textfield instance name

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 2:52pm UTC](https://forum.kirupa.com/t/changin-font-size-on-the-fly/25658/6 "2003-07-15T14:52:21Z")

</div>

I’m not having any luck with it. Just for testing purposes, I applied the code to the main button which has the instance name “scroller.” The grey “font size 12” button is the one that would make the changes to all of the text. Here I’ll attach the .fla if you’re interested in looking, it may just be some small error on my part.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [July 15, 2003, 3:43pm UTC](https://forum.kirupa.com/t/changin-font-size-on-the-fly/25658/7 "2003-07-15T15:43:38Z")

</div>

First, you are not giving the correct path to the textfield.  
[http://www.kirupa.com/developer/actionscript/as\_tricks.htm](http://www.kirupa.com/developer/actionscript/as_tricks.htm) [read the 6th and 7th tutorials]  
And second, i dont think you can change a text inside a button. Make a movie clip with a textfield and a button inside and it will work.
