# Displaying variable in a text box?

**URL:** https://forum.kirupa.com/t/displaying-variable-in-a-text-box/110329
**Category:** Uncategorized
**Created:** [May 14, 2004, 6:57pm UTC](https://forum.kirupa.com/t/displaying-variable-in-a-text-box/110329 "2004-05-14T18:57:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![earleybird](https://avatars.discourse-cdn.com/v4/letter/e/a88e57/32.png) [@earleybird](https://forum.kirupa.com/u/earleybird)
#### Post date: [May 14, 2004, 6:57pm UTC](https://forum.kirupa.com/t/displaying-variable-in-a-text-box/110329/1 "2004-05-14T18:57:15Z")

</div>

Hi,

I have a tiny spaceship and I can control its direction and speed using the arrow keys. Its only a test for the moment so it looks pretty basic.

Anyway, now that I have that working I am trying to put in a dynamic text box which will display the speed of the spaceship as it slows down or speeds up. I’ve put the text box in a movieclip called “caption” on the same timeline as the space ship but I can’t get a reading.

The variable that holds the speed is called “speed” and the textbox in which i want to display the speed is called “carspeed”. I thought this might do it:

[color=blue]\_root.caption.carspeed = speed;[/color]  
[color=#0000ff][/color]  
[color=black]However I just keep getting “undefined” in the text box.[/color]  
[color=black][/color]  
[color=black]I’ve attatched the .fla so you can have a look.[/color]  
[color=black][/color]  
[color=black]Press the up arrow to go fwd and the down arrow to slow down and move backwards.[/color]  
[color=black][/color]  
[color=black]Any help would be greatly appreciated![/color]

Thanks!
