Skip to main content
June 23, 2007
Answered

Create controls inside a container?

  • June 23, 2007
  • 5 replies
  • 484 views
So I am now creating a checkbox at runtime with the following code:

import mx.controls.CheckBox;
createClassObject( CheckBox, "button2", 5, { label:"Test Checkbox" } );

Is there a way to create a button inside another object like a ScrollPane (or something else?)? I created a ScrollPane at designtime, and would like the checkboxes, as well as text and perhaps draw lines within it at runtime. Is this possible? If not, is there another container which would allow this?

I am trying this with the following code:

CounterScrollPane.createClassObject( CheckBox, "button3", 5, { label:"Test Checkbox" } );

but that doesn't work.

Any thoughts?

Thanks!
This topic has been closed for replies.
Correct answer Greg Dove
This should help:

5 replies

Inspiring
June 25, 2007
You're welcome.
(And of course it doesn't have to be a square...it could be whatever you want....it's basically just something to put in as the ScrollPane's content which serves as the parent clip for your checkbox)
June 25, 2007
Ok, I made a square and turned it into a movie clip with the same settings you listed (basically default), and now it is within the scroll pane and will cause it to scroll. Works very nice. Thanks for your help GWD!
Inspiring
June 25, 2007
I think you'll find that that won't scroll inside the scroll pane...I didn't try it but I'm pretty sure it has to be either the content of the scrollPane or a child clip of the content for it to scroll.

June 25, 2007
quote:

Originally posted by: GWD
I think you'll find that that won't scroll inside the scroll pane...I didn't try it but I'm pretty sure it has to be either the content of the scrollPane or a child clip of the content for it to scroll.


You are correct, it just creates it above the scrollpane. Let me try the other way. Thanks for the help again!
Inspiring
June 25, 2007
Sorry I didn't explain more. contentPath can be an external swf (in which case you need to wait for it to load.

But it can also be a movieclip in the library set with its linkage identifier to the name used in the contentPath property of a container component. That's what I did here.

a. I made a square, turned it into a movieclip..
b. then in the library, right-clicked it, and chose linkage
c. in the identifier field (it probably already has something) put the name you want to use in contentPath
d. make sure that export for actionscript is checked and in first frame

Greg DoveCorrect answer
Inspiring
June 23, 2007
This should help:

June 25, 2007
Thanks for the response, but I am still having trouble. I think my problem is with the contentPath part. What needs to be there? You said it is an empty clip with the identifier as "square". Is this a movie clip? What was used to make it? Any more information on this would be appreciated!

Thanks!
June 25, 2007
nevermind, I got it using the following code:

var testScrollPane:ScrollPane = attachMovie( "ScrollPane", "test_sp", 10 );
testScrollPane.createClassObject( CheckBox, "button2", 5, { label:"Test Checkbox" } )
testScrollPane.setSize( 500, 200 );