Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


set selected item of combobox

Posted on 2004-11-16
Medium Priority
Last Modified: 2007-12-19

what is the best way to set the selected item of a combobox when i only have the data that i want to be selected?

thanks - Trevor
Question by:trevorhartman
  • 2

Expert Comment

ID: 12601639
What exactly are you trying to do? There are a couple of ways to set the data within a combo box. One is to dynamically retrieve the data from an external source (i.e. XML file or database) while the other is to hard code the data directly by editing the "labels" in the Parameters tab of the properties toolbar.

Does that help at all?

Brian Fidler

Author Comment

ID: 12601650
I don't mean set the data, or give it a data source, or populate the combobox.

let's say I have a prepopulated combobox.  All data was set in flash by me.  Now in actoinscript i dynamically want to tell it to select the item whose value is "x"

whats the best way?

thx - Trevor
LVL 39

Accepted Solution

blue-genie earned 1000 total points
ID: 12601950
Hi Trevor,

here's an option.

use an array to store all your data values for your combobox.
then using a function, return the index (i.e location in array) of that value.

since both the combobox index and array index are 0 based (i.e. start at 0) , you then know which item to select.

in other words.
in your main timeline... //myBox_cb being the instance name of the cb

Array.prototype.getIndex = function(data) {
      for (i=0; i<this.length; ++i) {
            if (this[i] == data) {
                  return i;
      return -1;
boxData = new Array("1", "2", "3"); //put your data values here
location = boxData.getIndex("2"); //specify which is the item you want selected

ps. based and tested on Flash UI Components 1 (flash mx).


Author Comment

ID: 12607176

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question