Solved

problem with creating a comboBox dynamically in Flash MX 2004

Posted on 2004-09-30
1
226 Views
Last Modified: 2010-04-03
Hi, I am using Flash MX 2004 pro and I have the following code below that:

1.  Generates several ComboBoxes dynamically in a For Loop which works fine.
2.  Generates the Ids for these ComboBoxes dynamically using Arrays, then use these Ids to do 'addItem' to the ComboBoxes.

Step 2 above is not working. Looking at my code below is there an alternative solution to this?

thanks in advance

-------------------------------------------------------------------
import mx.controls.ComboBox;
var YPOS:Number;
YPOS = 10;

var MyComboBox_Array:Array;
MyComboBox_Array = new Array();

for(i=0; i < 3; i++)
{
  MyComboBox_Array[i] = "ComboBox_" + i;
  createClassObject(ComboBox, MyComboBox_Array[i], this.getNextHighestDepth(), {_x:10, _y:YPOS});
  MyComboBox_Array[i].addItem({label:"option1", data:0});
  MyComboBox_Array[i].addItem({label:"option2", data:1});
  MyComboBox_Array[i].addItem({label:"option3", data:2});

  YPOS = YPOS + 100;
}
------------------------------------------------------------------------

0
Comment
Question by:dmehran
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
muso120999 earned 250 total points
ID: 12193652
You are just referencing the combobox by name, you need to reference it as an object:

import mx.controls.ComboBox;
var YPOS:Number;
YPOS = 10;

var MyComboBox_Array:Array;
MyComboBox_Array = new Array();

for(i=0; i < 3; i++)
{
  MyComboBox_Array[i] = "ComboBox_" + i;
  createClassObject(ComboBox, MyComboBox_Array[i], this.getNextHighestDepth(), {_x:10, _y:YPOS});
  _root[MyComboBox_Array[i]].addItem({label:"option1", data:0});
  _root[MyComboBox_Array[i]].addItem({label:"option2", data:1});
  _root[MyComboBox_Array[i]].addItem({label:"option3", data:2});

  YPOS = YPOS + 100;
}
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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. …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

696 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