# Change dynamic textfield value in Flash

**URL:** <https://forum.kirupa.com/t/change-dynamic-textfield-value-in-flash/260821>\
**Category:** flash\
**Created:** [May 20, 2008, 7:17am UTC](https://forum.kirupa.com/t/change-dynamic-textfield-value-in-flash/260821 "2008-05-20T07:17:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sindarin](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@Sindarin](https://forum.kirupa.com/u/Sindarin)\
**Post date:** [May 20, 2008, 7:17am UTC](https://forum.kirupa.com/t/change-dynamic-textfield-value-in-flash/260821/1 "2008-05-20T07:17:10Z")

</div>

Hello, I am trying to migrate from AS2 because AS3 looks more practical.  
However with actionscript 2, I would just create a new dynamic textfield, set it to variable testvar and simply write at a frame or button press,

> \*\*var \*\*testvar = testvar+2  
> That would increase the variable +2 each time and the textfield would just show it.

How I can achieve the same effect with Actionscript 3? I am well aware that components like textarea cannot have actionscript assigned to them anymore.

---

<div class="post-metadata">

**Author:** ![Alex\_Lexcuk](https://avatars.discourse-cdn.com/v4/letter/a/919ad9/32.png) [@Alex\_Lexcuk](https://forum.kirupa.com/u/Alex_Lexcuk)\
**Post date:** [May 20, 2008, 7:57am UTC](https://forum.kirupa.com/t/change-dynamic-textfield-value-in-flash/260821/2 "2008-05-20T07:57:27Z")

</div>

Create in the work field dynamic textfield  
set Instanse name, exsample my\_txt  
in first frame code

```auto

var testvar:int=0;
var stop_trigger:int=1;

//frame chalenger
addEventListener(Event.ENTER_FRAME, EntFr);
dispatchEvent(new Event(Event.ENTER_FRAME));
function EntFr(e:Event):void {
if (stop_trigger==1) {my_txt.text=my_txt.text+" This_mega_good_"+testvar++;	
  if (testvar>25) {my_txt.text="";testvar=0;}
  }
}

//button mode
my_mc.buttonMode=true;
my_mc.addEventListener(MouseEvent.MOUSE_UP,my_mc_press);
function my_mc_press(MouseEvent)
{
if (stop_trigger==0) {my_mc.gotoAndStop(1); stop_trigger=1;} 
else {my_mc.gotoAndStop(2);stop_trigger=0;}
}

```

Example test need  
[http://murmadillo.tut.su/fla/Text\_chalenger.swf](http://murmadillo.tut.su/fla/Text_chalenger.swf)  
[http://murmadillo.tut.su/fla/text\_chalenger.rar](http://murmadillo.tut.su/fla/text_chalenger.rar)

---

<div class="post-metadata">

**Author:** ![Sindarin](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@Sindarin](https://forum.kirupa.com/u/Sindarin)\
**Post date:** [May 20, 2008, 2:10pm UTC](https://forum.kirupa.com/t/change-dynamic-textfield-value-in-flash/260821/3 "2008-05-20T14:10:23Z")

</div>

Thank you, it’s all clearer now.
