Haykel BEN JEMIA wrote:
> You get the message because getChildAt returns a DisplayObject which 
> does not have a getChildAt method (that's what the error message is 
> saying). You have first to cast the object returned from the first 
> getChildAt call to a DisplayObjectContainer or a subclass of it (in 
> your case it's a VBox). There are different ways to do it, one way 
> would be:
>
> var theVidButton:VBox = (vidButtonBox.getChildAt(0) as 
> VBox).getChildAt(0) as VBox;
>
> You must make sure that vidButtonBox.getChildAt(0) will return a VBox 
> otherwise you will get an exception! It's better to do something like 
> this:
>
> var theVidButton:VBox = null;
> var vidButtonContainer:VBox = vidButtonBox.getChildAt(0) as VBox;
> if (vidButtonContainer != null)
> {
>   theVidButton = vidButtonContainer.getChildAt(0) as VBox;
> }
>
> if (theVidButton == null)
> {
>   //something went wrong
> }
>
> Hope it helps!
>


Yes that helps greatly. Now I am able to access the child, but it seems 
to not be the child I raised.
I can't set a style on it.
I tried this, and it compiled but causes the error below.
(vidButtonBox.getChildAt(0) as VBox).(getChildAt(0) as 
VBox).setStyle("backgroundAlpha","0");

ypeError: Error #1123: Filter operator not supported on type 
mx.containers.VBox.
    at Main/mouseUpVidButton()[K:\xampp\htdocs\jbh\Main.mxml:203]

I usually have no trouble setting a backgroundAlpha on a VBox, so why is 
it telling me the filter operator is not supported ?

>
> On Sat, Oct 4, 2008 at 4:51 PM, [EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]> <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> 
> wrote:
>
>
>     I have a VBox in mxml called vidButtonBox
>     <mx:VBox id="vidButtonBox" height="435" width="215"
>     styleName="vidButtonBoxStyle" paddingLeft="10" paddingRight="10" >
>     </mx:VBox>
>
>     In action script, I create a VBox with a Vbox child
>     var vidArea:VBox = new VBox;
>     var vidButton:VBox=newBbox;
>     vidArea.addChild(vidButton);
>
>     then add that to the mxml Box
>     vidButtonBox.addChild(vidArea);
>
>     Then I try to access the children
>     var theVidButton:VBox= vidButtonBox.getChildAt(0).getChildAt(0);
>
>     And I get this error:
>     K:\xampp\htdocs\jbh\Main.mxml(145): Error: Call to a possibly
>     undefined
>     method getChildAt through a reference with static type
>     flash.display:DisplayObject.
>
>     This makes no sense at all. What is going on here ? How do I access
>     child[0].child[0]?
>
>
>
>
> -- 
> Haykel Ben Jemia
>
> Allmas
> Web & RIA Development
> http://www.allmas-tn.com
>
>
>  

Reply via email to