Solved

problem with creating a comboBox dynamically in Flash MX 2004

Posted on 2004-09-30
1
208 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now