Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dyn Text - On a button 2

Status
Not open for further replies.

alokwww

Technical User
Dec 25, 2002
86
I'm sure this has been answered somewher before but I cant seem to find it so here goes:

I have a button that onclick mutes and then onclick again unmutes and keeps doing that over and over. I was wondering if there was a way to make the text on the button change to "mute" on the second click and "unmute" on the firstclick. My main question is, how do you define the value on a dynamic texbox?
Thanks
-Alok
 
give the button an instance name and access its label property to change the text.
 
If you don't want to use a component, just add another layer on your button in edit mode. Add a dynamic textfield and give it an instance name like button1Text. Then simply set that text with...

_root.my_button1.button1Text.text = "Mute";

Then you can use this as your button's script:

on(release){
if(_level0.but1muted == false){
stopAllSounds();
// Or mySound.stop();
_root.my_button1.button1Text.text = "Unmute";
_level0.but1muted = true;
} else {
mySound.start(0,999);
_root.my_button1.button1Text.text = "Mute";
_level0.but1muted = false;
}
}

Regards,

oldman3.gif


Don't worry, if my reply is wrong, BillWatson will clean it up for me!
 
Ok! Corrections... On my above post...

If you don't want to use a component, just add another layer on your button in edit mode. Add a dynamic textfield and give it a variable name, like button1Text. Then simply set that text with...

_root.button1Text = "Mute";

Then you can use this as your button's script:

on(release){
if(_level0.but1muted == false){
stopAllSounds();
// Or mySound.stop();
_root.button1Text = "Unmute";
_level0.but1muted = true;
} else {
mySound.start(0,999);
_root.button1Text = "Mute";
_level0.but1muted = false;
}
}

Or add a dynamic textfield on a layer over your button, but not in the button's edit mode. Than you can set the text with...

_root.button2Text.text = "Mute";

Then you can use this as your button's script:

on(release){
if(_level0.but2muted == false){
stopAllSounds();
// Or mySound.stop();
_root.button2Text.text = "Unmute";
_level0.but2muted = true;
} else {
mySound.start(0,999);
_root.button2Text.text = "Mute";
_level0.but2muted = false;
}
}

Regards,

oldman3.gif


Don't worry, if my reply is wrong, BillWatson will clean it up for me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top