画布(Canvas)容器 对 子类 进行 绝对值 定位,应用(Application)容器、面板(Panel)容器 可选择 绝对值 定位 或 相对值 定位。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
	<mx:Panel title="控件 定位 示例(Positioning Controls)" width="50%" height="50%" layout="absolute">
	    <!-- 定义 按钮 坐标为 距离 面板 左上角(20 像素,20 像素) -->
		<mx:Button id="button1" label="按钮" x="20" y="20" width="160" height="25"/>
	</mx:Panel>
</mx:Application>




[img]/upload/attachment/115826/5e9cbde3-6677-3741-95aa-8b64c9dc2a4b.png[/img]


控件定位



下面的 代码片段 是在 运行时 动态调整定位 控件 绝对位置。当单击 按钮控件时,从当前位置 移动按钮 向右、向下 个 10 像素。


<mx:Button id="btn" label="按钮" x="0" y="250" height="20" click="btn.x+=10; btn.y+=10;"/>