# Text field arrangement and attaching onRelease

**URL:** https://forum.kirupa.com/t/text-field-arrangement-and-attaching-onrelease/332179
**Category:** flash
**Created:** [February 22, 2014, 3:57pm UTC](https://forum.kirupa.com/t/text-field-arrangement-and-attaching-onrelease/332179 "2014-02-22T15:57:47Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mrhartsclube](https://avatars.discourse-cdn.com/v4/letter/m/67e7ee/32.png) [@mrhartsclube](https://forum.kirupa.com/u/mrhartsclube)
#### Post date: [February 22, 2014, 3:57pm UTC](https://forum.kirupa.com/t/text-field-arrangement-and-attaching-onrelease/332179/1 "2014-02-22T15:57:47Z")

</div>

I written this code but its not working:

```php

on (release) {
    for (i = 1; i <= 5; i++)
    {
        var container:MovieClip = this.createEmptyMovieClip(container*, this.getNextHighestDepth());
        var label:TextField = this.container*.createTextField(label*, 1, 0, 0, 300, 100);

        this.container*.done* = true;

        this.container*.label*.text = "TXT0";
        this.container*.label*.selectable = false;
        this.container*.label*.autoSize = true;

        this.container*._x = 150;
        if (i != 1)
        {
            this.container*.label*._y = this.container[i-1]._y + this.container[i-1]._height + 10;
        }
        this.container*.onRelease = function()
        {

            if (this.done*)
            {
                this.label*.text = "TXT2
TXT2";
                this.done* = false;
            }
            else
            {
                this.label*.text = "TXT1";
                this.done* = true;
            }

                this.label*._y = _parent.container[i-1]._y + _parent.container[i-1]._height + 10;
        };
        if (i == 1)
        {
            // no onEnterFrame for the first Textfield
            continue;
        }
        this.container*.onEnterFrame = function()
        {
            this.label*._y = _parent.container[i-1]._y + _parent.container[i-1]._height + 10;
        };
    }
}

```

I want to dynamically create some textfields (5 in this example) and vertically place them next to each other (**[COLOR=#ff0000]\_y=\_y+\_height+10[/COLOR]** in this example). I also want to add an \*\*[COLOR=#ff0000]onRelease [/COLOR]\*_event for each of them which checks [COLOR=#ff0000]done[/COLOR]_ (default is true) to toggle change clicked text to another text and back, also in the same time rearrange all textfields if one of textfields height changed.

What I get when I compile my code is the first and second textfields are arranged as I want but the other 3 textfields placed on textfield2, and also \*\*[COLOR=#ff0000]onRelease [/COLOR]\*\*does not work!

NOTE:  
I replaced[COLOR=#ff0000] **[“container”+i.toString()]**[/COLOR] with _[COLOR=#ff0000]container[/COLOR]_\* and same for _[COLOR=#ff0000][FONT=arial]done[/FONT][/COLOR]_\* and \*_[COLOR=#ff0000][FONT=arial]label_ [/FONT][/COLOR]\*\*for readability! [FONT=impact](I know the code will not work because of these replacements, but it can be read better in this mode)[/FONT] and also added some line breaks!
