[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to change caption of "button" symbol & call different functions???

Posted on 2006-05-04
10
Medium Priority
?
174 Views
Last Modified: 2010-04-03
HI,
I have a button in my application with tha caption of button as "dynamic text" field. Now by default caption of button will be "PLAY", but when I click on button its caption should change to "PAUSE". Also depending on its caption I want to call 2 different functions in my actionscript.
How to do this??
Please help me.

Thanx in advance
prash
0
Comment
Question by:Econify
  • 6
  • 4
10 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16603993
are you using Flash button component?

Rgds
Aneesh
0
 

Author Comment

by:Econify
ID: 16604016
I am using button symbol. (having 4 states up-over-down-hit)

Prash
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16604025
can you upload the sample FLA in which you have button symbol....?
or mail it to me, (mail is in profile)

Rgds
Aneesh
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Econify
ID: 16604074
Hi anish,
I sent u mail of the fla file of button. PLease have a look at it & let me know solution.
Thanx.
Prash
0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 1500 total points
ID: 16604078
Hi,

1.
you should keep the text outside the button, means just one layer above to the button.
because, inside button nothing is accessible using actionscript.

2.
now assign the instancename to button as "myButton"; and you have text with instancename "play_text" on root.

3.
now create a new layer for actionscript and paste the following actionscript
----------
myButton.onRelease = function() {
      if (play_text.text == "Play") {
            playFunction();
            play_text.text = "Pause";
      } else {
            pauseFunction();
            play_text.text = "Play";
      }
};
playFunction = function () {
      trace("play function gets called");
};
pauseFunction = function () {
      trace("pause function gets called");
};
----------

4.
compile and test

Rgds
Aneesh
0
 

Author Comment

by:Econify
ID: 16604187
Hi anish ,
Thanx.

It worked for me.
I will give u full points.
Just a simple question:-
On clicking this button I want to hide another button named "next_btn".
How to do this??
PLs tell me.
Thanx again.
Prash
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16604238
just add the following line of code in "myButton.onRelease" function

----------
next_btn._visible=false;
---------
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16604252
here is the complete code:

---------
myButton.onRelease = function() {
     if (play_text.text == "Play") {
          playFunction();
          play_text.text = "Pause";
     } else {
          pauseFunction();
          play_text.text = "Play";
     }
     next_btn._visible=false;

};
playFunction = function () {
     trace("play function gets called");
};
pauseFunction = function () {
     trace("pause function gets called");
};
-------------
0
 

Author Comment

by:Econify
ID: 16604643
THANX A LOT!!!!!!!!!!!!!!!!!!
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16604659
surprisedly, you awarded Grade "B"

is there anything, you were not satisfy with the solution?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question