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!

Pill Button in Flash MX? 1

Status
Not open for further replies.

JuUaAn

Programmer
Jul 23, 2003
7
CA
Hi everyone,

I know there are premade buttons in the Flash MX Common Libraries. There's one particular button, the pill button that I don't know how to use. You'd think it's just a regular button but it's a movie clip. That's the reason why I don't know how to use it.

The button seems to be controlled using ActionScript. Could anyone tell me how to use this button? I want the button to trigger the playing of a movie clip when the user clicks on it.

Thanks a bunch!
 
i think u call a function from the changeHandler option in the button setup. to make a button component work..

not sure tho, search for changeHandler in your flash help file.


I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
OK, I've looked into this setClickHandler method. Now, the problem is that I don't know where to put the ActionScript code? Do I add the action to the button? Or do I add it to a keyframe?

Thanks!
 
keyframe if its in a function

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
simplest is just to give the button an instance name (my_btn, say) then add to the frame actions

my_btn.onRelease = function(){
//do something
}

_______________________________________
You know you're old if you can remember when bacon, eggs and sunshine were good for you
 
cool, :)

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Thanks for the help. I've tried it but it still doesn't work for some reason. I really want to get this resolved so let's take an example. This is with Flash MX btw.
1. Starting with a fresh fla, I open up the Common Library with the buttons.

2. Under the Component Buttons, I drag the pill button onto the stage.

3. Now, I add a keyframe to frame 15 and type something on the stage and then I throw a stop() action in it so that the movie doesn't loop.

4. I click on the button and name the button my_btn.

5. I click on Frame 1 and add...
my_btn.onRelease = function() {
gotoAndStop("Scene 1", 15);
};
...to the actions.

6. I add a layer and I put a stop() action to the first frame of layer 2 so that the movie doesn't run.

So now, if things work, when you click the button, it should skip to frame 15. But it doesn't. What is wrong???
Thanks again for your help![2thumbsup]
 
my_btn.onRelease = function() {
trace("clicked");
};

try that in authoring and make sure the trace appears then you will now the problem lies with the goto statement.


_______________________________________
You know you're old if you can remember when bacon, eggs and sunshine were good for you
 
Thanks for the quick reply. I really appreciate it. Nothing happens when I test the movie and click the button. There's no output window that pops up when I click it.

I put that code in Frame 1 of layer 1 right? That's where my button is located.
 
Ok, I've figured it out. You add the actions to the Actions layer inside the button symbol. Then it works!

Thank you so much billwatson for your help and insight. It's helped me a lot![thumbsup2]
 
glad it works but i meant for the code to go on the main timeline


_______________________________________
You know you're old if you can remember when bacon, eggs and sunshine were good for you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top