views:

294

answers:

2

Why does the following button not line up 100px from the left edge?

<mx:Button left="100"></mx:Button>

I am using the Flex 4(Gumbo) SDK, I am pretty sure that if you try to do it in FlashBuilder, it would work.

+1  A: 

Check if you have it nested in some other component.

In this example button will be placed 200px left (100px for panel + 100px button for button left attribute)

<s:Panel x="100" y="100" width="250" height="200">
    <mx:Button left="100"></mx:Button>
</s:Panel>
dd
nested? Could you please explain, It is the only component in the application so far.
sigvardsen
This is my entire application:<?xml version="1.0" encoding="utf-8"?><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > <mx:Panel x="100" y="100" width="250" height="200"> <mx:Button left="100"></mx:Button> </mx:Panel></mx:Application>This is my output file:http://sitoon.com/labs/isoperior.swf
sigvardsen
I assume nested is asking if you happen to have the component inside a "Canvas" or something similar. If you are on a relative layout, or using relative layout for that specific control, then it will be 100 away from the canvas, rather than the side of the window.
Sivvy
You have the button embedded in a panel. It's relative to the Panel's position. Change it to absolute, or make it "0" relative to the panel.
Sivvy
+1  A: 

Are you using absolute or relative layout?

<mx:Application Layout="absolute">

And if trying either of those doesn't work... I don't think I've ever seen someone use "left" (I'm sure it works, but it looks odd to me). Try changing "left" to "x":

<mx:Button x="100" />
Sivvy
Thank you, it works.I agree that using it for left is odd, but it is practicle for a resizable application, when using left, right, top, bottom.
sigvardsen
Remember... It works, but it depends if that's how you want ALL the components to act. If you have controls within a panel of canvas, all controls will be placed according to the absolute value, rather than relative to the parent component.
Sivvy