You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Seema Makkar <se...@aricent.com> on 2013/11/13 12:34:06 UTC
Unable to get children from VBox
Hello all,
This is very simple example, I want to get child from click method through rawChildren but giving null values.
Below is the implementation, please help. I need to add List at runtime.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" creationComplete="application1_creationCompleteHandler(event)"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.controls.List;
import mx.events.FlexEvent;
protected var wBox:DisplayObject;
var lstControl:List;
protected function b1_clickHandler(event:MouseEvent):void
{
wBox=vbox.rawChildren.getChildByName("lstControl");
Alert.show(wBox+":::::::::::;");
}
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
lstControl= new List();
vbox.addChild(lstControl);
//vbox.addChild();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox id="vbox" creationPolicy="All">
<s:Button id="b1" click="b1_clickHandler(event)">
</s:Button>
<s:Button id="b2">
</s:Button>
</mx:VBox>
</s:Application>
Thanks,
Seema
===============================================================================
Please refer to http://www.aricent.com/legal/email_disclaimer.html
for important disclosures regarding this electronic communication.
===============================================================================
RE: Unable to get children from VBox
Posted by "Michael A. Labriola" <la...@digitalprimates.net>.
>wBox=vbox.rawChildren.getChildByName("lstControl");
>lstControl= new List();
>vbox.addChild(lstControl);
This probably belongs on the user list. So, continued the discussion there. getChildByName() works based on the child's name, not the name of a variable that you used to instantiate and add the child.
Also, there is no need to use rawChildren here.
If in your b1_clickHandler you said:
Alert.show( vbox.numChildren) you should see it has 3.
Mike