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

Using a combobox to navigate to scenes with as3

Guest
Jan 16, 2012 Jan 16, 2012

Copy link to clipboard

Copied

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

}

TOPICS
ActionScript

Views

2.1K

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Jan 16, 2012 Jan 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");

   }

}

Votes

Translate

Translate
LEGEND ,
Jan 16, 2012 Jan 16, 2012

Copy link to clipboard

Copied

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

   }

}

Votes

Translate

Translate

Report

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
Guest
Jan 16, 2012 Jan 16, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
LEGEND ,
Jan 16, 2012 Jan 16, 2012

Copy link to clipboard

Copied

You're welcome

Votes

Translate

Translate

Report

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
Participant ,
Apr 14, 2023 Apr 14, 2023

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

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 ,
Apr 14, 2023 Apr 14, 2023

Copy link to clipboard

Copied

@hclmed0 

 

as3 or html5?

Votes

Translate

Translate

Report

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
Participant ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

AS3. It has a mile of parameters, most of which seem to be related to cosmetics which, (apart from a transparency and font size issue), I'm not concerned about. The functions it seems to offer for export are:

fl.controls.listClasses.CellRenderer

fl.controls.ScrollBar

fl.controls.ComboBox

fl.controls.List

fl.controls.Textinput

Votes

Translate

Translate

Report

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 ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

if your combobox instance name is cb and you can use:

 

cb.addEventListener(Event.CHANGE,cbF);

function cbF(e:Event):void{

// the selected label is e.currentTarget.selectedItem.label

// the selected data is e.currentTarget.selectedItem.data

}

Votes

Translate

Translate

Report

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
Participant ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

Perfect. Worked like a charm. Thank you.

Votes

Translate

Translate

Report

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 ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

you're welcome.

Votes

Translate

Translate

Report

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
Participant ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

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.

ComboBoxOverRefLayout.png

Votes

Translate

Translate

Report

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 ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

the default is alpha100%, or not at all transparent. ie, your code or cb properties are causing that change from default.

Votes

Translate

Translate

Report

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
Participant ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

create a test fla

add a combobox (cb) to the stage

assign some labels to the cb

test

 

how's it look?

Votes

Translate

Translate

Report

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
Participant ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

The pulldown does turn opaque on mouseover, but I don't see how to make it opaque when inactive. I now see that the default text size was already 12, so it did change when I set it higher using the parameters in your other thread. So that's working. 

cbImage.png

I guess I can't attach an .fla.

Votes

Translate

Translate

Report

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 ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

what's the combobox look like when not moused over?

Votes

Translate

Translate

Report

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
Participant ,
Apr 15, 2023 Apr 15, 2023

Copy link to clipboard

Copied

That screen grab was when not moused over. Actually it's still partially transparent even when moused over.

The is the code over the square with the gradient on a 512x512 stage.

// comboBox settings
var pulldownVal:int
var tfor:TextFormat = new TextFormat();
tfor.size = 22;
cb_1.textField.setStyle("textFormat", tfor);
cb_1.setStyle("disabledTextFormat", tfor);
cb_1.dropdown.setRendererStyle("textFormat", tfor);

stop();

cb_1.addEventListener(Event.CHANGE,cb1F);
function cb1F(e:Event):void{

// the selected label is e.currentTarget.selectedItem.label

pulldownVal = e.currentTarget.selectedItem.data
trace(pulldownVal);

}

Votes

Translate

Translate

Report

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 ,
Apr 16, 2023 Apr 16, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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
Participant ,
Apr 17, 2023 Apr 17, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

comboboxes consist of these items

 

kglad_0-1681743541206.png

 

Votes

Translate

Translate

Report

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
Participant ,
Apr 17, 2023 Apr 17, 2023

Copy link to clipboard

Copied

This is still confusing since, when I saw that list, it didn't show the alpha property that, after I guessed it, is what fixed the transparency. Is there a list that includes that, and also the type of argument each one uses?

Votes

Translate

Translate

Report

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
Participant ,
Apr 17, 2023 Apr 17, 2023

Copy link to clipboard

Copied

Also found the property for dropdown height:

cb.dropdown.rowHeight = 40;

 

Votes

Translate

Translate

Report

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 ,
Apr 18, 2023 Apr 18, 2023

Copy link to clipboard

Copied

yes, you would check the as3 api for everything listed, combobox, textinput, cellrenderer, list plus all the datatypes returned by the properties/methods of those.

Votes

Translate

Translate

Report

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
Participant ,
Apr 18, 2023 Apr 18, 2023

Copy link to clipboard

Copied

I have been pouring through the reference at https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/controls/ComboBox.html

But among it's miles of attributes, it didn't list .alpha, the one that finally worked, anywhere. Then I'm still hoping to set its boundary thickness and color and pulldown button color, but its not clear where those are accessed. I only stumbled on the methods to control:

cb.alpha = 100;
cb.dropdown.rowHeight = 40;
cb.selectedIndex=3;

Some of the entries are more direct than other. For example, TextFormat: https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/text/TextFormat.html, gives the list of parameters and their data types. Other components, like comboBox, while including the many operations it has, doesn't give that simple list of parameters. It looks like the flash.text has a navigable hierarchy, while other component are more sprawling and harder to search. So I'm not even sure where to start searching for the parameters that could be applied to turn the upper, default appearance, to the appearance below:

ComboBoxOverRefLayout.png

 

Votes

Translate

Translate

Report

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 ,
Apr 18, 2023 Apr 18, 2023

Copy link to clipboard

Copied

alpha is an inherited property.  make sure you checking inherited properties, too:

 

kglad_0-1681866191877.png

 

Votes

Translate

Translate

Report

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