# Dynamic text in buttons?

**URL:** <https://forum.kirupa.com/t/dynamic-text-in-buttons/16378>\
**Category:** Uncategorized\
**Created:** [March 24, 2003, 10:56am UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378 "2003-03-24T10:56:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jns](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jns](https://forum.kirupa.com/u/jns)\
**Post date:** [March 24, 2003, 10:56am UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/1 "2003-03-24T10:56:37Z")

</div>

i would like to create a model-button which i can use several times. the textline should come from a variable…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 11:40am UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/2 "2003-03-24T11:40:28Z")

</div>

see **Array (object)**, **for** and **MovieClip.attachMovie** in the actionscript dictionary 😉 =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 11:49am UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/3 "2003-03-24T11:49:48Z")

</div>

you can use something like that:

- make a mc, place a button inside this mc.
- add one layer for actions and one layer for the **dynamic** txt box, on this mc, on top of the button layer.
- select the **dynamic** text box and on properties panel write _label_ on the var field.
- on the actions layer pplace this code:  
[AS]  
label=this.\_name;  
[/AS]

* * *

there! now you have a generic button that will have the text matching his instance name.

for the actions on these buttons you can use something like that:  
[AS]  
on (press){  
getURL(this.\_name+".html");  
}  
[/AS]  
😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 11:56am UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/4 "2003-03-24T11:56:21Z")

</div>

wow :!:

that is nice kax!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 12:03pm UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/5 "2003-03-24T12:03:34Z")

</div>

thanks =) 😛

but assuming he’s just started with flash… yours is easier to understand 😉 =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 1:06pm UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/6 "2003-03-24T13:06:09Z")

</div>

thanks to you guys. i will work with your examples…  
and you are right kax, i’m just starting with flash, but hope to give it back to the community someday what i get from you guys…

but one more question: so it’s not possible to add a dynamic textfield to an ordinary macrom. button in each frame?

thanks again…  
jns

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 1:13pm UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/7 "2003-03-24T13:13:03Z")

</div>

yeah, you can. =)

but now that **mx** allows you to have mouse events [size=1]onPress onRelease onReleaseOutside onRollOut onRollOver onDragOut onDragOver[/size] in movie clips… it’s more _practical_ [size=1]at least for me[/size] use movie clips instead of buttons 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 6:23pm UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/8 "2003-03-24T18:23:34Z")

</div>

so i worked around with your scripts and there both really fine.  
**kax** script is nice, but i have already so much functions to my buttons that i will use it somewhere else…  
[COLOR=blue] **Guig0s** [/COLOR] script works fine, but unfortunately i have to use the instance name for a mouseover script (see: [http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18263](http://www.kirupaforum.com/forums/showthread.php?s=&threadid=18263))  
maybe you have a hint to solve this problem??? would be fantastic…  
thanks a lot…:hangover:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 6:37pm UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/9 "2003-03-24T18:37:18Z")

</div>

well you can assign the label to a variable instead of the clip´s \_name.

something like:

[AS]  
label = buttonName;  
[/AS]  
instead of  
[AS]label = this.\_name  
[/AS]

and on main stage you place this code:  
[AS]  
\_root. **button1**.buttonName= home;  
\_root. **button2**.buttonName= portfolio;  
…  
[/AS]  
where **button1** , **button2** … is the instance name of your buttons.

got it?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 8:49pm UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/10 "2003-03-24T20:49:16Z")

</div>

perfect!!  
yeah!!!  
thank you very very much!!!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 24, 2003, 8:51pm UTC](https://forum.kirupa.com/t/dynamic-text-in-buttons/16378/11 "2003-03-24T20:51:17Z")

</div>

np dude 😉

glad to help =)
