--- In [email protected], "Ciarán" <[EMAIL PROTECTED]> wrote:
>
> Hi Mark,
Hi Ciarán

Thanks for your answer.

I can see your point, so I'll try to illustrate what I'm doing and
trying to achieve:

In the application, I have a <mx:tile id="tile1"/>
In a HTTPService Result Handler, I loop through the result and add a
component (spreadView) to tile1.

Now each component (spreadView) has a function that will add children
til it (see below function pageHandler)

I have clipped alot of var's etc from the code, to save some space -
and it's still quite messy, so please bear with me.

Again : Basicly I need to access a childObject of a childObject in a
Tile - Have been looking at rawchildren, which doesn't really bring me
anywhere, propably wrong usage !!
Any helpers is greatly appreciated, it might (obviously) also be, that
I am doint his all wrong, should I avoid using a Component, and
instead "build" each component in AS ?

Thanks for your time!

Best regards,
Mark

                private var newspread:SpreadView = null;
                private function pageHandler(event:ResultEvent):void {
                        tile1.removeAllChildren();
                        if (event.result.action.pageset is ObjectProxy) {
                                pages.addItem( event.result.action.pageset ) ;
                        } else {
                                pages = event.result.action.pageset;
                        }
                        for (var i:int=0;i<pages.length;i++){
                                //trace( pages[i].left.page.pageid );
                                newspread = new SpreadView();
                                newspread.leftPageID = 
pages[i].left.page.pageid;               
                                newspread.rightPageID = 
pages[i].right.page.pageid;
                                tile1.addChild(newspread);
                        }
                }

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml";
creationComplete="init()" width="100%" height="100%">
<mx:Script>
        <![CDATA[
                import mx.controls.Image;
                import mx.containers.Canvas;
                
                
                private function init():void {
                        // Clear the canvas of any children
                        initLeft();
                        initRight();
                        this.name = leftPageNo +" "+ leftPageTitle +"-"+ 
rightPageNo +" "+
rightPageTitle;
                }
                private var leftThumb:Image = null;
                private var rightThumb:Image = null;
                private var lc:Canvas = null;
                private var rc:Canvas = null;
                
                private function initLeft():void{                        
                        lc = new Canvas;
                        lc.id = "leftCanvas";
                        lc.percentHeight = 100;
                        lc.percentWidth = 50;
                        lc.verticalScrollPolicy = "off";
                        lc.horizontalScrollPolicy = "off";
                        if (leftIsRegion) {
                                lc.setStyle("backgroundColor", 0x00C4FF);
                        } else {
                                //lc.setStyle("backGroundColor", 0xFFFFFF);
                        }
                        mainbox.addChild(lc);
                        
                        leftThumb = new Image();
                        leftThumb.name = "leftThumb";
                        leftThumb.source = leftImgLink;
                        leftThumb.id = leftPageNo;
                        leftThumb.scaleX = 1;
                        leftThumb.scaleY = 1;
                        leftThumb.y = 10;
                        leftThumb.toolTip = leftImgLink;
                        lc.addChild(leftThumb);
                        
                        if (leftHasSwift) {
                                leftFooter.setStyle("backgroundColor", 
0xFFFF00);
                        } else {
                                leftFooter.setStyle("backgroundColor", 
0xFFFFFF);
                        }
                        
                        leftPageno.text = leftPageNo +" "+ leftPageTitle;
                }

                private function initRight():void{
                        rc = new Canvas;
                        rc.name = "rightCanvas";
                        rc.percentHeight = 100;
                        rc.percentWidth = 50;
                        rc.verticalScrollPolicy = "off";
                        rc.horizontalScrollPolicy = "off";
                        if (rightIsRegion) {
                                rc.setStyle("backgroundColor", 0x00C4FF);
                        } else {
                                //rc.setStyle("backgroundColor", 0xFFFFFF);
                        }
                        mainbox.addChild(rc);
                        
                        rightThumb = new Image();
                        rightThumb.name = "rightThumb";
                        rightThumb.source = rightImgLink;
                        rightThumb.name = rightPageNo;
                        rightThumb.scaleX = 1;
                        rightThumb..scaleY = 1;
                        rightThumb.y = 10;
                        rightThumb.toolTip = rightImgLink;
                        rc.addChild(rightThumb);
                        
                        if (rightHasSwift) {
                                rightFooter.setStyle("backgroundColor", 
0xFFFF00);
                        } else {
                                rightFooter.setStyle("backgroundColor", 
0xFFFFFF);
                        }
                        rightPageno.text = rightPageNo +" "+ rightPageTitle;
                }
                
        ]]>
</mx:Script>
        <mx:HBox horizontalGap="0" id="mainbox" width="100%"
click="{this.parentDocument.currentState='spreadView'};{this.parentDocument.switchImage(leftImgLinkHi,
rightImgLinkHi)}" />
        <mx:HBox width="100%" id="hbox1">
        <mx:Canvas id="leftFooter"  width="50%">
                <mx:Label id="leftPageno" textAlign="left" text="leftFooter"
width="100%"/>
        </mx:Canvas>
        <mx:Canvas id="rightFooter" width="50%">
                <mx:Label id="rightPageno" textAlign="right" text="rightFooter"
width="100%" />
        </mx:Canvas>
        </mx:HBox>
</mx:VBox>

> 
> Your question is quite vague, a solid example of what you're trying to
> achieve might clear things up a bit.
> 
> To access children, use the getChildAt() method, or if you're trying
> to access non-display children:
> 
> http://livedocs.adobe.com/flex/201/html/containers_intro_063_25.html
> 
> tile.getChildAt(0) will return the first child, then a further
> getChildAt(0) on the child will return the first child of the child
> and so on.
> 
> If you're treating the contents of the Tile container like list data,
> then investigate using the TileList control instead.
> 
> Best Regards,
> Ciarán
> 

Reply via email to