Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help with targetSection?

New Here ,
Feb 23, 2013 Feb 23, 2013

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

TOPICS
ActionScript
292
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2013 Feb 23, 2013
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines