2 Replies Latest reply on Jul 6, 2009 5:00 AM by kloysen

    Simple actionscript problem

    kloysen Level 1

      I am currently developing an app in which I have multiple panes which are different components.  In one component I need to draw a tree structure made of a custom component I have developed.  The problem is that when I add the nodes to the parent component (a panel), they are drawn on top and outside of it.  I debugged to make sure that the nodes were in fact children of the parent so its not that.  It might move something to do in how they are drawn in which I call the move function to place it on coordinates that reflect where in the tree they should be placed.  If anyone has any help I would be greatly appreciated.



        • 1. Re: Simple actionscript problem
          Eliezer Reis Level 1

          I don't know how you're doing it but if ,in fact, the components aren't children of parent you can try to use the parent.addChild(UIComponent) method.


          I'll be easier to see if you post some code.

          • 2. Re: Simple actionscript problem
            kloysen Level 1

            private function renderStack(instances:Array, leftPos:Number, top:Number):StackDetails
                        var maxWidth:Number = 0;
                        var maxHeight:Number= 0;
                        var i:int;
                        var verticalGap:Number = VERTICAL_GAP;
                        var horizontalGap:Number = HORIZONTAL_GAP;
                        var selectedInstance:UIComponent = null;
                        // first, we want all of the renderers in our stack to be the same size,
                        // so we're going to iterate through them and get the maximum length of
                        // the renderers.
                        var left:Number = (width  / 2) - instances[0].width;
                        // OK, now we actually stack our components, top to bottom.
                        for(i = 0;i<instances.length;i++){
                            // for each component
                            var inst:UIComponent = instances[i];
                            // if this renderer represents a selected item, we're going to remember that, because later on we'll want
                            // to store its baseline in our cached details.
                            // advance our marker for where the top of the next component should go.
                            left += inst.width + horizontalGap;


                        // store off the information we've calculated that we'll be needing later.               
                        var details:StackDetails = new StackDetails();
                        details.top = top;
                        details.bottom = top + maxHeight;
                        details.left = 0;
                        details.right = left + maxWidth;
                        details.leftPos = leftPos
                        return details;


            and the private class StackDetails


            class StackDetails
                // the position top of the stack, in pixels
                public var top:Number;
                // the position of the bottom of the stack, in pixels;
                public var bottom:Number;
                // the position of the left of the stack, in pixels;
                public var left:Number;
                // the position of the right of the stack, in pixels;
                public var right:Number;
                // the index of the selected item in the stack, if it exists. NaN otherwise.
                public var selectedIndex:Number;
                // the vertical position of the baseline of the selected item in the stack, if it exists, in pixels.
                public var selectionBaseline:Number;
                public var leftPos:Number
                public var childrenInRow:Number;



            also i am attaching a picture of what it looks like with some dummy data in it