0
votes

I've read a lot of articles saying that in order to use the old "Layout='Absolute'" in Flex 4, I simply have to use

<s:layout>
    <s:BasicLayout/>
</s:layout>

But it just doesn't work the same way. On Flex 3, when you set your application layout as absolute, the X and Y properties automatically lose their utility since every component of your layout will be determined automatically by default in the top left of your screen. It works similarly as the mobile layouts: You either use Canvas to set X and Y (most used by mobile game developers) or you let the device to place everything so it will avoid screen size problems and such.

Is it still possible on Flex 4? How harder/complex is it? Thanks for your attention.

Edit -------

So it seem a little bit confuse what I want. Back to Flex e, I used to do this:

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onInit()" width="100%" height="100%"

I started my application with this tag and down there I would have a box container with 100% width and 100% height. So, inside this box container I would have HBox and VBox to align my components (now VGroup and HGroup). The thing is that in Flex 3 I could place 1 VBox, for instance, and 3 HBox inside it that each HBox would assume a position automatically one under the other, that is with X and Y properties blank. With Flex 4, when I place 1 VGroup and 3 HGroup inside without setting any X and Y propert, they'll just fill up one above the other, like if I had set X,Y = 0 to all of them. They don't assume position one under the other like it used to.

1
Using layout="absolute" in Flex 3 will place components according to their x and y properties. So does <s:BasicLayout> in Flex 4.Timofei Davydik
Yeah, but in flex 3 if I don't set any x and y, they'll be placed in running time, which in Flex 4 BasicLayout doesn't work. If I don't set any X and Y, all components will be floating one inside the other.Marco Aurélio Deleu
What do you mean "placed in running time"? Please, tell, what do you want to doTimofei Davydik
I'm gonna edit the main post to try to clarify it better.Marco Aurélio Deleu
Guess you use new components (VGroup, HGroup) incorrect. Flex4 BasicLayout works absolutely same way as "layout=absolute" in Flex 3 - i have this in all my applications.radistao

1 Answers

0
votes

Please see the Flex 3 to Flex 4 equivalent layouts in Spark Layouts with Flex 4:

Working with the Spark Layouts

Because layouts and containers are separated in Spark, there are a few notable changes that you need to take into account when working with the layouts. Take a moment to examine the following table of MX layout container classes and their corresponding combination of Spark layout and container:

MX Containers Corresponding combination of Spark Layout and Container
Canvas        Group with BasicLayout (no advanced constraints)
HBox          Group with HorizontalLayout (or the HGroup class)
VBox          Group with VerticalLayout (or the VGroup class)
Tile          Group with TileLayout
List          List with VerticalLayout
TileList      List with TileLayout

In your case, it sounds like you want a dynamic layout rather than an absolute one because you say you do not want to supply X and Y coordinates for your controls.

You then have two options:

  • Use the BasicLayout and specify the top, left, right, bottom properties for your controls
  • Use HorizontalLayout, VerticalLayout, or one of the other dynamic layouts.