Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Components Within Components

I'm having some strange behavior that I'm trying to understand/work-around.

I have create a custom component which I call 'VComboBox' (this is the linkageID). This custom component is made up of two of Flash's builtin components, the first is a simple text label, the second is the ComboBox known as 'FComboBoxSymbol'. The instance of the combo box within my custom component is named 'comboObject'.

Now on my stage when I drag an instance of this custom component from my library to the stage, and name it 'myCustomComponent'. I can use the following code:

_root.myCustomComponent.comboObject.addItem("red", 0);

Then when I run the page it works fine. The combo is populated and clicking on the arrow indeed brings down the drop-down view of the combo box. However when I try to implement this fine piece of code dynamically I run into a MUCH different story. Below is the code:

var newControlName = "control" + instanceCounter++;
_root.attachMovie("VComboBox", newControlName, depth++);
_root[newControlName].comboObject.addItem("red", 0);

Now when I run the page it indeed creates a copy of my custom component. However nothing shows up inside, whereas it would display "red" before. And when I click on the arrow to drop the list down, nothing happens except for turning the entire combo box grey.

What gives? How could I make this work? I despirately need my components to work so that a database can dynamically create the needed fields to collect the data that it requires.

Sameal
Sign In or Register to comment.