Skip to main content
Participant
February 23, 2013
Question

Help with targetSection?

  • February 23, 2013
  • 1 reply
  • 304 views

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);

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
February 24, 2013

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.