Skip to main content
Known Participant
January 26, 2009
Question

Combo Boxes reseting in Actionscript

  • January 26, 2009
  • 4 replies
  • 498 views

I have created a menu for an online café. The display area is limited, so the menu items need to scroll within a frame of some sort.
The menu items come in various sizes for example “small”, “medium”, “large”.
Each size has a different cost.
For example “Cappuccino” has “Cappuccino Small”, “Cappuccino Medium”, “Cappuccino Large” with prices say “3.00”, “6.00”, “9.00”.

I have set up a Combo box to display each menu item.

This is all explained under the ActionScript 2.0 category, but I have been advised I have submitted it in the wrong place. So I’m now inserting it here. I have left out the Combo box code included in the other entry.

I have a number of problems (see other entry under ActionScript 2)
Here is problem one again, I’ve tried a number of solutions, this one looked more promising.

Problem1
How does one reset the ComboBox to the “Home” position using ActionScript (CS3)? I tried using “myCappuccinoBox.setSelectedIndex(0);” with button Click. Among a variety of other attempts this seemed the most likely solution, but still gave an error “call to undefined method through a reference with static type fl.controls.ComboBox”. Do I have to add some other access statement e.g. “fl.controls.?????”. Does someone know how to reset my menu items?
This topic has been closed for replies.

4 replies

fungus13Author
Known Participant
January 29, 2009
Thanks for your reply,
I was beginning to wonder if there were a solution
I will try that.
I named the box "myCappuccinoBox" (=cbx)
I had thought the error was focussed on the "setSelectedIndex" component


Damon Edwards
Inspiring
January 28, 2009
give your dynamically created combobox a name, ie:
cbx = new comboBox();
cbx.name = "MyBox";
addChild(cbx);

Then reference it like so:

ComboBox(getChildByName("MyBox")).setSelectedIndex(0);
fungus13Author
Known Participant
January 28, 2009
I have just found a similar problem on another forum. The answer was
ComboBoxInstancename.setSelectedIndex(0);
I assume this applies to a ComboBox created via the "Components" which would have an instance name.
My ComboBox is created DYNAMICALLY with ActionScript code
Can anyone complete the picture and tell me what I am doing wrong. I thought I was on the right track and now am even more confident that I am heading in the right direction.
Can anyone advise whether I need to load additional code?
I loaded
"import fl.controls.ComboBox;" action the ComboBox
Do I need to load something else to action the reset?
Also can someone advise on the terminology here.
would it be "importing a class method" or what?
Hopeful
fungus13Author
Known Participant
January 27, 2009
Well, when I get a problem it is a good one. Not an easy solution I guess. Have to admit I tried quite a few ideas, but the one listed looked the most promising.