PDA

View Full Version : Dynamically creating CheckBoxes, weird result


edgecrusher
08-07-2004, 02:53 PM
Hi,
Im trying to get this code to create 3 CheckBoxes nicely alligned, and all of them with a selected = TRUE, value.
And then get those values on an array.
But this is what it gives me.

1. - It creates the three CheckBoxes.. but the first one is not alligned with the others.. it is created on the top left corner of the stage (0,0)...

2.- Also this first appears as unchecked, although when I retrieve the MyCheckboxArray, the results are: true, true, true.

Any Ideas? :


for (i=0; i<3; i++) {

createClassObject(mx.controls.CheckBox, "MyCheckbox"+i, i, {label:"whatever", groupName:"checkies", fontFamily:"fuentemenu", fontSize:"8"});
_root["MyCheckbox"+i].setSize(130, 20);
_root["MyCheckbox"+i].move(20, 110+30*i);
_root["MyCheckbox"+i].selected = true;
_root.MyCheckboxArray[i] = _root["MyCheckbox"+i].selected;
}

edgecrusher
08-09-2004, 05:39 PM
Anyone?
Help me see the light :confused:

theflux
08-12-2004, 12:39 AM
Let me start by saying that in general components require quite a bit of "Voodoo" to get working correctly. I see you are using createClassObject to create the components. You may want to check out this page at macromedia (http://www.macromedia.com/support/flash/ts/documents/add_component.htm) as well as this post (http://www.actionscript.org/forums/showthread.php3?t=50198&highlight=create+component). I personallly have had trouble with both methods, and components in general. The frustrating thing is that it seems like most developers on this board and many others do not use the v2 components, and absolutely have no knowledge about the v2 professional components. I'm sorry if this wasn't much help, I'm currently in the trenches with you trying to get components to work on my own projects - its not easy =P
Keith

bleepbloop
08-17-2004, 11:16 AM
I have a problem that I feel may be related.

I have built my own component that extends MovieClip
The component is appearing in the components panel and is behaving itself if I drag an instance of it onto the stage in design time.

However I would like to attach it through code using the createClassComponent method, and it is not doing so. Should I have extended a V2 class instead of a MovieClip class? And which one should I extend.

And mores to the point, how the frick am I to find this information out other than by trawling forums endlessly. Have I missed a crucial part of MM's documentation here?

(continues to moan about MM's support for mx 2004 pro documentation at length to anyone within earshot.......)

edgecrusher
08-17-2004, 11:29 AM
Well I solved my problem... Im not sure how..
I just rewrote a lot of code I was getting trouble with, and that Create Check Box ended inside a function that pretty much dynamically creates a bunch of clips, textfields and the checkboxes.
And it worked..

So I guess the problem was not the createClassObject, but something on my code.

Anyway, Im puzzled as why it didnt work before.. And I hope I dont get many more jobs that need components... the ScrollPane gave me so much fight, I ended up an using an old fashioned DIY scroller.
With the amount of time I spent trying to figure out the ScrollPane issues (forums, a couple of books, trial and error, sacrificing chickens, hitting the PC with a sledgehammer, etc) I could have wrote three different approachs for DIY scrollers, and will not have aged 10 years in two weeks.