Skip to main content
January 16, 2012
Answered

Using a combobox to navigate to scenes with as3

  • January 16, 2012
  • 1 reply
  • 3846 views

I'm a novice.  I'm trying to use a combobox to navigate to different scene in my .fla.  I was able to use a conditional (if) statement which seems to work but it only allows me to use the "if" and "else if" statement once before giving an error.  i examined information on using a "switch" but haven't had any luck understanding the coding or getting it to work.  The following is the code I've wrote.  Can anyone provide me some guidance?  Thanks in advance.

cb1.addEventListener(Event.CHANGE, home_dl);

function home_dl(e:Event)

{

    if (cb1.selectedItem.label == "A - B")

    {

        gotoAndPlay(65, "a-b");

}

    else if (cb1.selectedItem.label == "C - D")

        gotoAndPlay(65, "c-d");

}

This topic has been closed for replies.
Correct answer Ned Murphy

At a quick glance it looks like you are missing an opening curly brace following your second if()

else if (cb1.selectedItem.label == "C - D") {

Also, while it is probably just a copy/paste error, you are short one closing brace for the function

function home_dl(e:Event)

{

    if (cb1.selectedItem.label == "A - B")

    {

        gotoAndPlay(65, "a-b");

    }

    else if (cb1.selectedItem.label == "C - D") {

        gotoAndPlay(65, "c-d");

   }

}

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
January 16, 2012

At a quick glance it looks like you are missing an opening curly brace following your second if()

else if (cb1.selectedItem.label == "C - D") {

Also, while it is probably just a copy/paste error, you are short one closing brace for the function

function home_dl(e:Event)

{

    if (cb1.selectedItem.label == "A - B")

    {

        gotoAndPlay(65, "a-b");

    }

    else if (cb1.selectedItem.label == "C - D") {

        gotoAndPlay(65, "c-d");

   }

}

January 16, 2012

You're a gentleman and a scholar.  It worked like a charm.  Thank you again.

Ned Murphy
Legend
January 16, 2012

You're welcome