View Full Version : addChild() a component on top of everything
cpthk
07-29-2009, 07:57 AM
Hi:
I am using addChild() to add component dynamically inside a panel. But I realized if the panel is too small to fit the new component, the panel will automatically expand to fit in the new component. But I would like the component to be on top of everything and could across to outside region of the panel, which the panel stay the original size and does not expand to fit it.
For example:
Just like the textInput validator, the warning message is across outside the panel, and the panel stays at original size. How do I do that?
http://www.actionscript.org/forums/attachment.php3?attachmentid=31817&stc=1&d=1248851041
shubs6
07-29-2009, 01:25 PM
Which is this component? Are you setting percentheight and percentwidth of the component? Coz in that case re-size shall occur.
If you can give the code I may be able to help you better.
cpthk
07-29-2009, 07:55 PM
To make an example:
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" ...
...
<ms:script>
private function addList():void{
var newList:List = new List();
newList.x = 0;
newList.y = 0;
newList.height = 200;
newList.width = 200;
addChild(newList);
}
</ms:script>
</mx:Panel>
In the middle of program, when user do some action, my code will call this function to create an List component. Then my panel container will expend itself to fit this List component if the List is larger. But I just want my List to be large that could across into outside of the panel, just like the validation warning message I have shown in my previous post.
Dr.Mabuse
07-29-2009, 10:05 PM
Why not add the List to the parent application instead of the component itself?
All UIComponents have a reference to the main application through the parentApplication property.
Just replace:
addChild(newList);
with:
parentApplication.addChild(newList);
Or you could set the List includeInLayout property to false, that would also probably work.
cpthk
08-04-2009, 06:50 AM
Why not add the List to the parent application instead of the component itself?
All UIComponents have a reference to the main application through the parentApplication property.
Just replace:
addChild(newList);
with:
parentApplication.addChild(newList);
Or you could set the List includeInLayout property to false, that would also probably work.
I think you meant parentDocument.
Thanks, may I ask another question.
If I do parentDocument.addChild(newList); Does this component still belongs to this or parentDocument? If the parentDocument read some data from this, does that work? or I have to identify like: comp.xxx
Dr.Mabuse
08-04-2009, 07:47 AM
Nope, I actually meant parentApplication. parentDocument will work if the parent document is the topmost element in the displayList of the application.
Adding it to the parentApplication makes sure it will end on top of every other element in the application (if you squint you can look at parentApplication as a sort of root). Remember to set the parent document/applications layout property to absolute for this to work.
The component will still be part of your component, even if you add it to the parent document or application. Just make sure to save it in a local variable.
rebelheart
08-04-2009, 05:59 PM
If you want it on 'top of everything' then you might want to use popupmanager .Look at systemmanager as well to get an idea about how UI components are layered.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.