# Add Input field at runtime - AS problem

**URL:** <https://forum.kirupa.com/t/add-input-field-at-runtime-as-problem/205807>\
**Category:** flash\
**Created:** [November 2, 2006, 4:08am UTC](https://forum.kirupa.com/t/add-input-field-at-runtime-as-problem/205807 "2006-11-02T04:08:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![evynco](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/evynco/32/2159_2.png) [@evynco](https://forum.kirupa.com/u/evynco)\
**Post date:** [November 2, 2006, 4:08am UTC](https://forum.kirupa.com/t/add-input-field-at-runtime-as-problem/205807/1 "2006-11-02T04:08:58Z")

</div>

Ok, basically, how do I add input fields ONE AT A TIME at runtime, so that I can UNDO them, one by one ?

This is a ‘Whiteboard’ function and I’ve done the above for lines and shapes, no worries.

However, when I try to add Input text fields in the same way (one by one) nothing appears on screen.

This is the working code for drawing squares:

> \_root.canvas[“stroke”+d].lineStyle(2, 0xcb6f14, 100);  
> \_root.canvas[“stroke”+d].moveTo( xm, ym );  
> //\_root.canvas[“stroke”+d].beginFill( 0xcb6f14 );

\_root.canvas[“stroke”+d].lineTo( (xm + \_global.dia), ym);  
\_root.canvas[“stroke”+d].lineTo( (xm + \_global.dia), (ym - \_global.dia));  
\_root.canvas[“stroke”+d].lineTo( xm, (ym - \_global.dia));  
\_root.canvas[“stroke”+d].lineTo( xm, ym);

…so you can see \_root.canvas[“stroke”+d] is the array which increments with each item drawn. This works fine, users can UNDO one entry at a time.

Now, the same idea for the input text fields:

> \_root.canvas[“stroke”+d].createTextField(“mytext”,1,\_xmouse,\_ymouse,300,20);

\_root.canvas[“stroke”+d].mytext.type = “input”;  
\_root.canvas[“stroke”+d].mytext.selectable = true;  
\_root.canvas[“stroke”+d].mytext.multiline = true;  
\_root.canvas[“stroke”+d].mytext.wordWrap = true;  
\_root.canvas[“stroke”+d].mytext.autoSize = true;

myformat = new TextFormat();

myformat.color = 0xcb6f14;  
myformat.bullet = false;  
myformat.underline = false;  
myformat.size= \_global.textsize;  
myformat.font = “\_sans”;

\_root.canvas[“stroke”+d].mytext.setNewTextFormat(myformat);

Does this make sense to anyone ? Has anyone achieved this before ?  
I can send the full code…

Thanks so much.😑

Puzzled, Australia.
