Solved

problem with creating a comboBox dynamically in Flash MX 2004

Posted on 2004-09-30
1
221 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
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

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…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

730 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