PDA

View Full Version : how to duplicate buttons so that they...


iflashyou
03-23-2006, 02:25 AM
how do you duplicate a button so that it still has the actions you gave it?

or do i have to give links to each and every button separately?

Grant B
03-25-2006, 03:42 AM
You can do what you want.

Ideally - you would start to use movie clips as buttons as you can do much more with them.

If you have an instance of something in the library - right click on the library item and choose duplicate. Any actionscript contained within that item will also be duplicated.

It depends on what you are doing or plan to do. Sometimes it pays to have seperate functions for each button and call those functions from the main timeline. (not forgetting to give each movie clip an instance name in the properties field.) But you can basically do what you want. Movie clips as buttons will give you more scope.

http://www.kirupa.com is a great place to learn both the basics and the advanced stuff. Get used to visiting that site and using the search facility. http://search.atomz.com/search/?sp-advanced=1&sp-q=buttons&B1=search&sp-a=00040c2f-sp00000000&sp-w-control=1;

sophistikat
03-25-2006, 04:08 AM
you can't but there are methods around this. why do you want to duplicate your buttons and why would you want the duplicated button to have the same code as the original?

not as simple as// original buttons onPress handler
my_btn.onPress = function () {
trace(this._name);
}

// duplicate
my_btn.duplicateMovieClip("btn2", _root.getNextHighestDepth(), {_x: 200});can workfunction btnPress () {
trace("btn pressed");
}
// original buttons onPress handler
my_btn.onPress = function () {
btnPress();
}

// duplicate
my_btn.duplicateMovieClip("btn2", _root.getNextHighestDepth(), {_x: 200});
btn2.onPress = function () {
btnPress();
}