Multiple previous/next buttons in actionscript 3.0?
Copy link to clipboard
Copied
first off all, I'm incredibly new to flash and actionscript 3 (I literally had never even touched flash until last week), so I'm sorry if this is a silly question.
basically my problem is this:
I need to make several sets of previous/next buttons that each control different sets of images/keyframes. I already know how to make 1 set of buttons, but I'm not entirely sure how to add more without having them affect ALL the images instead of the ones I need them to. (like I said, I'm really new to coding, so I'm not sure how to make the buttons respond to a specific root)
Copy link to clipboard
Copied
There are a variety of ways one might implement a previous / nest scenario. Very often it can be realized using just one button for each direction of play. If you explain how you have things set up it will be easier to try to help.
Copy link to clipboard
Copied
well, this time around I'm aiming to make a simple customizer/dress up game that uses buttons to switch between items. my current set up has all the different items + the code distributed throughout several keyframes on the same layer. this is the code I'm using :
button1.addEventListener(MouseEvent.CLICK, backward);
button2.addEventListener(MouseEvent.CLICK, forward);
function forward(event:MouseEvent) {
if (this.currentFrame == this.totalFrames) {
gotoAndStop(1);
}
else {
nextFrame();
}
}
function backward(event:MouseEvent) {
if (this.currentFrame == 1) {
gotoAndStop(this.totalFrames);
}
else
{
prevFrame();
}
}
(of course, I don't really need both buttons, but I'm using the full code for now)
the code works fine, but like I said I can only get it to work for one set of buttons. so let's say that I want to be able to change between a set of different shirts and a set of different pants. I'm able to make a button/buttons that works for the shirts, but I don't know how to make an additional button that only changes the pants. basically, I need to stop the button for shirts and the button for pants from interfering with each other.
(I'm sorry if this wasn't the info you needed, or if I didn't explain it properly. as I said, I'm new to this, and this is mostly just practice for a bigger project I have planned)
Copy link to clipboard
Copied
For the code you show, that code could be used to manage the entire timeline if you just leave it in frame 1 and have that layer and the buttons that relate to it extend the full length of the timeline. So you will have the same two buttons to control movement for the entire timeline... no need to repeat them anywhere because they will then exist everywhere.
I have no idea how that code relates to choosing shirts and pants since it appears to do nothing of the sort.
Copy link to clipboard
Copied
the stuff about shirt and pants was just an example to illustrate that I need different buttons to control different things. I've already tried doing what you suggest, but it just makes all the different things move at once when I need to be able to move them separately.
Copy link to clipboard
Copied
That code makes nothing move except the position on the timeline. You will need to explain how moving along the timeline affects control of different things.
Copy link to clipboard
Copied
well then...allow me to try another example. let's say I want to create a simple scene that the player can interact with. something like this:
I want the player to be able to switch between several different trees and several different flowers. my problem is that I can't seem to get these two sets of buttons to work separately. I don't want one button to change both the trees and the flowers, I want several buttons so that I can change them independently of each other. this is what I don't know how to do, because everything I've tried just makes the flowers and the trees move together as one.
I'm very sorry if this still isn't enough, but I honestly don't know ow else to explain it.
Copy link to clipboard
Copied
Sample back and next button
stop();
btnNext.addEventListener(MouseEvent.CLICK, puntaNext);
function puntaNext(m:MouseEvent)
{
var frameNgayon:int;
frameNgayon = this.currentFrame;
gotoAndStop(frameNgayon + 1);
}
btnBack.addEventListener(MouseEvent.CLICK, puntaBack);
function puntaBack(m:MouseEvent)
{
var frameNgayon:int;
frameNgayon = this.currentFrame;
gotoAndStop(frameNgayon - 1);
}

