Centering text Vertically in a dynamic text box in flash

Hi guys,

Does anyone know if it is possible to centre text vertically in a dynamic text box in flash?

I’ve had a look around and can’t find any buttons which will do the job for me.


I don’t believe it’s possible through the authoring tool, although you could set up a movie clip (or component) that would center text vertically within an area with a bit of actionscript, I believe.

In MX you can set the alignment to center on the properties panel for the text field. Are you using 5 or MX? You can stil lexport to 5 from MX with center alignment, I don’t have 5 so I can’t tell you if its possible from the 5 authoring tool

i’m using mx…
surely you’re talking about horizontal alignment…
because there is a “centre text” button for horizontal alignment… but there isn’t one for vertical alignment…

Yep I misread that.

Does the text box have a border or something, can’t you just use actionscript to move the textfields _y property to make it look like its vertically aligned middle. Or am i missing somehting here?

no because the textfield is a specific dimension, and the text within can either be two lines long or just one line long.

if its just 1 line long I want the text to be vertically aligned to the centre.

So moving the textfield y position isnt going to make any difference.

Any other ideas chaps?

yes you can centre the text verticley by using html tags in your text file

<p valign=“middle”>blahblah</p>

you just have to enable the dynamic text box to parse html by selecting it in the DTB’s properties box

You can use ActionScript to set the TextField’s autoSize, multiline, and wordWrap properties to obtain the desired sizing behaviour. Your ActionScript can then read the _height property of the field and use it to set the _y property to vertically centre the field within the desired area.

Hi - could anyone tell me whether this technqiue works under Flash 6? It seems a really simple and perfect fix for what I’m looking for, but I’m not certain it will work with Flash 6.

I know some html text commands did, but I’m not aware of this one. Any help? :confused:

Andy, anything stopping you from trying?

Yes. I have Flash 7 player installed on every PC I have access to. Hence when I view it, I am viewing the Flash file via the Flash 7 player.

I’m trying to find out if the Flash 6 player supports it.

A bit like with Flash MX and setting a “<li>” value to html text. If the user had Flash 6 player it would show as a bullet point, whereas if a user had the Flash 5 player installed it wouldn’t show up.

Sorry I didn’t make myself clear. I’m going for your method anyway now as I cannot get the <p valign=\“middle\”> to work.

I tried it in both MX and MX2004Pro and this solution didn’t work.


The solution of valign = “middle” dosen’t work … :frowning:

I think, the text-box control dosen’t support this feature at all