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
Solved

problem with creating a comboBox dynamically in Flash MX 2004

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

Suggested Solutions

Title # Comments Views Activity
Reduce the size of the Flash SWF file it executes 12 419
Google Chrome - Where is "Enable Resource Tracking" 2 12,212
How to convert image files to a movie file 6 111
Flash ActionScript 6 57
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…
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…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
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.

860 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