Hi, I'm new to AS3. I have a slideshow with 4 slides. They are all in Scene 1 on the timeline. Each is on its own layer (and I have a fade effect between each of them on the timeline). I added labels to a separate layer in the timeline so that I could use forward and backward buttons to "speed up the process" in essence (instead of waiting for the slide to change). I can successfully use the buttons to cycle through the slideshow one time, but if I try to cycle through the slides more than once, I cannot get any further than the first slide.
I put this code on the buttons in the first frame of each labeled section on my timeline:
fwd_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_18);
function fl_ClickToGoToAndPlayFromFrame_18(event:MouseEvent):void
{
gotoAndPlay("Shopper_2");
}
back_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_19);
function fl_ClickToGoToAndPlayFromFrame_19(event:MouseEvent):void
{
gotoAndPlay("Shopper_1");
}
Any ideas?
Regards,
zerozone
Without seeing the timeline I can only hazard a guess. If you have the same buttons along the full length of the timeline, then what is probably happening is you are assging all those listeners to them, and they all remain in effect, so by the end, clicking them triggers each of the listeners, where the last always wins.
Try using just one listener and function for each button assigned in frame one. Use variables for the frame designations in the gotoAndPlay() calls. Then you just need to change the values of the variables at different stages of the timeline.
The code for the buttons would not change very much and would only be in frame 1. You would only be changing the functions to use variables for the gotoAndPlay() class
var fwdFrame:uint = ???; // use whatever the value would be for the goto in frame 1 normally
var backFrame = 1;
fwd_btn.addEventListener(MouseEvent.CLICK, fl_goForward);
function fl_goForward(event:MouseEvent):void {
gotoAndPlay(fwdFrame);
}
back_btn.addEventListener(MouseEvent.CLICK, fl_goBack);
function fl_goBack(event:MouseEvent):void {
gotoAndPlay(backFrame);
}
Make sure that layer extends the full tlength of the timeline so that the variables and functions are available all along it.
Then you just need to change the values of fedFrame and backFrame at each new stopping point on the timeline.
Thank you, Ned.
I think I'm getting closer, but it still isn't quite working. These are my 4 frame labels in the order in which they appear on the timeline:
So, now I have the following code on frame 1 of my "actions" layer:
var fwdFrame:uint = "shopper_2";
var backFrame = 1;
fwd_btn.addEventListener(MouseEvent.CLICK, fl_goForward);
function fl_goForward(event:MouseEvent):void
{
gotoAndPlay(fwdFrame);
}
back_btn.addEventListener(MouseEvent.CLICK, fl_goBack);
function fl_goBack(event:MouseEvent):void
{
gotoAndPlay(backFrame);
}
And then on the frames where the other slides start, I put the following on the "actions" layer:
var fwdFrame:uint = "retailer_1";
var backFrame = 1;
But unfortunately, it isn't working. I probably misunderstood something. These are the errors I get:
| Scene 1, Layer 'actions', Frame 155, Line 1 | 1151: A conflict exists with definition fwdFrame in namespace internal. |
| Scene 1, Layer 'actions', Frame 155, Line 2 | 1151: A conflict exists with definition backFrame in namespace internal. |
| Scene 1, Layer 'actions', Frame 305, Line 1 | 1151: A conflict exists with definition fwdFrame in namespace internal. |
| Scene 1, Layer 'actions', Frame 305, Line 2 | 1151: A conflict exists with definition backFrame in namespace internal. |
| Scene 1, Layer 'actions', Frame 455, Line 1 | 1151: A conflict exists with definition fwdFrame in namespace internal. |
| Scene 1, Layer 'actions', Frame 455, Line 2 | 1151: A conflict exists with definition backFrame in namespace internal. |
Regards,
zerozone
Ok, I did that. But now I'm getting these errors and the buttons still do not work:
| Scene 1, Layer 'actions', Frame 1, Line 1 | 1067: Implicit coercion of a value of type String to an unrelated type uint. |
| Scene 1, Layer 'actions', Frame 155, Line 1 | 1067: Implicit coercion of a value of type String to an unrelated type uint. |
| Scene 1, Layer 'actions', Frame 305, Line 1 | 1067: Implicit coercion of a value of type String to an unrelated type uint. |
| Scene 1, Layer 'actions', Frame 455, Line 1 | 1067: Implicit coercion of a value of type String to an unrelated type uint. |
Regards,
zerozone
Frame labels (which are strings) is a better choice, especially if you anticipate changing the timeline. So you would just need to keep them all as String objects when you declare and assign them...
// frame 1
var fwdFrame:String = "retailer_1";
var backFrame:String = "someOtherLabel";
// other frames
fwdFrame = "omeOtherLabel3";
backFrame = "someOtherLabel2";
North America
Europe, Middle East and Africa
Asia Pacific