Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-10-2002, 08:22 PM   #1
Sameal
Nxovkn
 
Join Date: May 2002
Location: Chattanooga, TN
Posts: 37
Default Referencing SubComponents Inside Components

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
Sameal is offline   Reply With Quote
Old 06-11-2002, 12:39 AM   #2
leblob
Registered User
 
Join Date: May 2002
Location: France
Posts: 50
Default

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.
leblob is offline   Reply With Quote
Old 06-11-2002, 12:24 PM   #3
Sameal
Nxovkn
 
Join Date: May 2002
Location: Chattanooga, TN
Posts: 37
Default

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?
Sameal is offline   Reply With Quote
Old 06-11-2002, 01:40 PM   #4
Sameal
Nxovkn
 
Join Date: May 2002
Location: Chattanooga, TN
Posts: 37
Default Da Answer!!!

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 01:42 PM.
Sameal is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

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 04:00 PM
Text 'Jumping' inside components bug. bwilpon Components 1 09-02-2004 08:17 PM
help needed referencing a component instance inside my own custom component bleepbloop Components 4 08-06-2004 10:31 PM
cannot interact with components inside duplicated movieclip! grizjr ActionScript 2.0 4 08-01-2004 07:53 PM
referencing from inside a movie clip? clownsquad ActionScript 1.0 (and below) 2 10-23-2001 10:45 PM


All times are GMT. The time now is 09:40 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.