Copy link to clipboard
Copied
I have a elevator interface where 3 buttons that target different sections (floors) on the timeline. Everything is working fine except when I try to click on a button that is not the first floor(which is the first on the timeline). For example, when I go to test movie, and try to click on the buttons for the second or third floor first, the doors open to the content for the first floor. But after that then i can randomly select whichever floor i want. Any tips?
Here is the code I have in the actions layer:
stop();
var targetSection:String = "";
button_1.addEventListener(MouseEvent.CLICK, onClick);
button_2.addEventListener(MouseEvent.CLICK, onClick);
button_3.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent){
switch(e.target.name) {
case "button_1":
targetSection = "floor1";
break;
case "button_2":
targetSection = "floor2";
break;
case "button_3":
targetSection = "floor3";
break;
}
play();
}
And at the end of each transition:
gotoAndPlay(targetSection);
Copy link to clipboard
Copied
try:
stop();
var targetSection:String = "";
button_1.addEventListener(MouseEvent.CLICK, onClick);
button_2.addEventListener(MouseEvent.CLICK, onClick);
button_3.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent){
switch(e.currentTarget.name) {
case "button_1":
targetSection = "floor1";
break;
case "button_2":
targetSection = "floor2";
break;
case "button_3":
targetSection = "floor3";
break;
}
play();
}
And at the end of each transition:
gotoAndPlay(targetSection);
if that fails use the trace() function to debug your code.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now