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
Brainiac
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 17, 2023

you're correct. the combobox (cb) by default is semi-transparent. i never realized that before.

 

this shows one way to style the parts of the cb, https://community.adobe.com/t5/animate-discussions/how-to-design-combobox/td-p/10551896


Since I need to do a lot of massaging to the cb component, I'm looking for a source for all of the addressable attributes for that, and other components.

I had been trying, incorrectly, to set that text format's alpha, when I realized that the cb itself is what needs to have it's alpha set. So I guessed at this parameter, and it worked for comboBox cb:

cb.alpha = 100;

So far, I've got control of several attributes with:

// comboBox settings
var tfor:TextFormat = new TextFormat();
tfor.font = "Arial";
tfor.size = 26;
tfor.color = 0x000000;
tfor.align = "right";

cb.textField.setStyle("textFormat", tfor);
cb.setStyle("disabledTextFormat", tfor);
cb.dropdown.setRendererStyle("textFormat", tfor);

// Set cb to opaque
cb.alpha = 100;

 

But I'm still looking for a list of all of the addressable properties for a component in general. So far, I've found this reference, which has many useful examples, but it doesn't seem to have an exhaustive list of the assignable style properties.

https://help.adobe.com/en_US/as3/components/flash_as3_components_help.pdf