| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Nxovkn
Join Date: May 2002
Location: Chattanooga, TN
Posts: 37
|
I have built a custom component which I call 'VComboBox'. This component is composed of a single label and an instance of Macromedia's builtin ComboBox 'FComboBoxSymbol'. I named the instance of the FComboBoxSymbol to 'comboObject'.
Now when I drag a copy of my component onto the stage and in ActionScript I use the following code: _root.myVComboInstance.comboObject.addItem("red", 0); It works and adds the item into the combo box inside my custom component. However when I dynamically create an instance of my VComboBox it does not work at all, like below: _root.attachMovie("VComboBox", myNewCombo, depth++); _root.myNewCombo.comboObject.addItem("red", 0); The combo appears but however no item is added. And when I click on the arrow for the combo to drop-down nothing happens. I am trying to find out what I am doing wrong? Is there a way to make this work? Also why is my custom component acting completely different based on whether it was created at design-time, or whether it was created dynamically at run-time? Any assistance would be greatly appreciated. Sameal ![]() |
|
|
|
|
|
#2 |
|
Registered User
Join Date: May 2002
Location: France
Posts: 50
|
Shouldn't it be
_root.attachMovie("VComboBox", "myNewCombo", depth++); rather than _root.attachMovie("VComboBox", myNewCombo, depth++); ? My guess is : if you don't use the quotes flash thinks myNewCombo is not the name to use but a variable in wich is stored the name to use. |
|
|
|
|
|
|
|
|
#3 |
|
Nxovkn
Join Date: May 2002
Location: Chattanooga, TN
Posts: 37
|
newControlName is a variable that is set just before the attachMovie() method.
It reads: newControlName = "control" + controlInstance++; _root.attachMovie("VComboBox", newControlName, depth++); _root.myNewCombo.comboObject.addItem("red", 0); If I was to enclose the variable newControlName with quotes then it would become a string literal which would not work in my case because I am dynamically creating any number of these VComboBox instances. My problem lies in the fact that when I instantiate the MovieClip in ActionScript it doesn't seem to behave at all the same as when it is drug onto the stage. Why is this? Do I need to do something extra to the MovieClip before using it? |
|
|
|
|
|
#4 |
|
Nxovkn
Join Date: May 2002
Location: Chattanooga, TN
Posts: 37
|
After much thought, and a good rest last night I have finally been able to figure out what is going on. My component isn't being swonked!!! Doh!
I was under the false illusion that swonking only had to do with loading and sending data to and from an outside source. However as I have learned today everything must be swonked. This is a very strange programming environment to me now, but I now see why it has to be this way. I placed an onLoad event on _root and sure enough my components were loading correctly when instantiated dynamically. I just needed to wait until they were done loading before I used a reference to them. For completion also the above examples are wrong, instead of: _root.newControlName.comboObject.addItem("red", 0); I was using... _root[newControlName].comboObject.addItem("red", 0); Just in case someone tries to recreate this they won't get stumped. Last edited by Sameal; 06-11-2002 at 02:42 PM.. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Why do components take so long to appear on stage? | xbrotherx | Components | 3 | 06-21-2006 05:00 PM |
| Text 'Jumping' inside components bug. | bwilpon | Components | 1 | 09-02-2004 09:17 PM |
| help needed referencing a component instance inside my own custom component | bleepbloop | Components | 4 | 08-06-2004 11:31 PM |
| cannot interact with components inside duplicated movieclip! | grizjr | ActionScript 2.0 | 4 | 08-01-2004 08:53 PM |
| referencing from inside a movie clip? | clownsquad | ActionScript 1.0 (and below) | 2 | 10-23-2001 11:45 PM |