3 Replies Latest reply on Apr 8, 2008 12:24 AM by slaingod

    dynamic component positioning in Panel

    forkiada Level 1
      Ok, here is the problem description which I have been trying to solve out for couple of weeks.
      I have a static ViewStack component in Flex Application, where I dynamically create a Panel component.
      I set up Style for Panel width and height, using setStyle("width",200) command.
      Then, in "for" loop I create a dynamic Grid 3x4 component (I also set up Styles for width and height ) where I load thumbnails of images (twelve images).
      In a loop I check whether number of images is bigger than 12.
      If so, then in a Panel I create also a dynamic Button that has a onclick event to proceed to another dynamic Panel with new thumbnail images, embedded in new Grid.
      The problem that I am having is that I cannot specify x and y position for dynamic button. So if I want to put it on the bottom of the dynamic Panel it is always placed under the grid, on the left. But that is not what I want.
      I have tried to use setStyle for x and y position but with no effect as well.
      I hope that I explained the problem well.
      Does anybody have similar problem? Or maybe I am doing something wrong here?
      Thanks!
      Here is a bit of code:

        • 1. Re: dynamic component positioning in Panel
          forkiada Level 1
          Anyone ? Please.
          How to place a dynamic button into a dynamic panel with specific x and y coordinates?
          • 2. Re: dynamic component positioning in Panel
            ntsiii Level 3
            You can't set dimensions, or x,y using setStyle, since they are properties.

            To explicitly place a component, you need a container that has absolute positioning. This can be a canvas, or a Panel with layout="absolute"

            If you need both, wrap the vertical layout component in an absolute one.

            Also look into contraint-based layout, if you haven't yet. using that you can specify, for instance, botton="5"

            Tracy
            • 3. Re: dynamic component positioning in Panel
              slaingod Level 1
              I do think this is a functionality that would be useful: Being able to position components, including z-order and visibility in style.

              You can accomplish similar stuff using the live compiler and config files, but from a 'pawn that off on the CSS design guy' mentality it would be nice.

              As far as your dynamic panel, you can use something like FlowBox or Flowsomething in the Flexlib on google to have things auto position, and then use setChildIndex to move them around and watch them reflow.

              But in general, you will use Canvas for absolute positioning, and simply put one of those into your Panel (or panel) and set the x and y of your new component in AS.

              So for instance in the above, you would simply do:
              p.width=300;
              rather than
              p.SetStyle('width','300');

              or

              g.x = 10;
              g.y = -5;