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

   }

}

Inspiring
April 14, 2023

I also have a comboBox question. I added one to a stage at a frame and I'm able to set a list of options, (name, value), when the Component Parameters menu appears after I click the component on the stage. I can then pulldown and select an entry when I run a test, but I'm not clear how I can receive and store the selected value.   Is there an example of how to get a value from the callback from that interaction?

 

Also, though a panel with font control is launched when the component is double clicked, it doesn't seem to address the very small font size in the pulldown values. Is there another properties menu that can set the font size for the values in the pulldown?

Inspiring
April 15, 2023

Not as critical, but its appearance seems to default to semi-transparent. Is there somewhere that can be changed to fully opaque? Also, none of the fl.controls.ComboBox parameters seem to address font size in the pulldown values. Is that accessible? Does this need to be converted to a symbol to get control of those attributes? This is the ComboBox overlapping the reference design.


That's what I would have thought, but I didn't assign any transparency in code and when I select the cb instance on the frame, the Object's Alpha is 100%. That's whats puzzling about what looks like its 50% transparency.There are no other layers above the one with the cb, other than the Actions layer. Are there other ways the tranparency could be changed? 

 

I'm also following your answers to the another thread on changing the cb font size here:

https://community.adobe.com/t5/animate-discussions/resize-combox-dropdown/m-p/4460302

I'm still poking at it, but the font size hasn't changed from that tiny size in the sample above.