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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assigning actions to multiple buttons 1

Status
Not open for further replies.

MGCGuy

Technical User
Oct 1, 2006
6
0
0
CA
Hi Folks,

I'm trying to set up a movie clip that will let me show an object with various types of lighting and controls that illuminate each lighting set, either individually, in combinations, or all together. Imagine, for example, something like a Christmas tree where the user has buttons that turn on the star on top, the strings of lights on the tree, and maybe some candles, but each type of light with its own control button (about 9 in all).

I have a series of images representing the different light groups displayed in all their possible on/off states. Is what I'm trying to do possible using Flash 8? If so, I'd really appreciate knowing how to do it.


Thanks and regards,
Michael
 
This should be fairly straight forward with Actionscript.
Are you familiar with Actionscript?
Are you putting your images on different frames on the timeline? If so, then you would put code on each button that directs the playhead to go to that frame.

If you're using classic buttons (not v2 component buttons), the code would look something like

myButton.onPress = function(){
gotoAndStop(<frameno>);
}

where '<frameno>' is the number of the frame containing your image for that button.

Assuming you're not familiar with Actionscript, you should put all Actionscript code on a separate layer on the timeline labeled something clever like 'Actionscript'. Lock this layer, so no graphics are put on it. Open the Actions panel and enter your code on frame one. Make sure your button is available on frame one as well in another layer.

If you want to use a v2 component button, the code is a little different and looks something like:

var myButtonListener:Object = new Object();
myButtonListener.click = function(){
gotoAndStop(<frameno>);
}
myV2Button.addEventListener("click", myButtonListener);

The V2 buttons allow you to listen to events broadcast from the button. You have to create a listener object and then create an event handler on that object. In this case the event handler is 'click'. Next you have to register your listener object with the button for the specific event, which is done using the 'addEventListener' method as shown.

If you already new all of this, I apologize. I just remember when I was first starting out getting buttons to work was a nightmare for me.
 
Hey Sherwood,

Thank you for your suggestion! :)


Regards,
Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top