Flex中的local, content, global坐标分析
2009-10-22 22:57
531 查看
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
注意:以下所有
global
,
local,content
坐标都是针对于上面这个组件而言的。
以上面这个组件
(
组件一,
comp1)
这例
,
假如当前这个文档的这一页为舞台
,
那么这个组件的左上角在该页面的坐标就是该组件的
global
坐标
.
现在假设在组件一中还有一个组件
(
组件二,
comp2)
,那组件二左上角的坐标则是组件一的
content
的
content
坐标,表示的是
comp2
在
comp1
的
content
中的绝对位置。
Content
的坐标原点不一定是在组件的原点,而是在组件的
content
的左上角。因此如果在
comp1
中添加了
comp2
,而且
comp2
的
x
,
y
都是固定的,那么
comp2
的左上角的
content
坐标在
comp1
的
content
中是不会变的,但是
local
坐标可能会变。因为
local
坐标永远是相对于
comp1
的左上角而言的。
<?xml version =
"1.0" encoding = "utf-8"?>
<mx:Application
xmlns:mx = " http://www.adobe.com/2006/mxml "
layout = "
absolute
"
>
<mx:Script>
<![CDATA[
import
mx.containers.Canvas;
private
function
showSupportingArea():
void
{
support.height=200;
var
point:Point=
new
Point();
//
point.x = lbl.x;
//
point.y = lbl.y;
//
point =
lbl.localToContent(point);
//
trace(point.x);trace(point.y);
//
point=lbl.contentToGlobal(point);
//
trace(point.x);
//
trace(point.y);
point=lbl.localToGlobal(point);
trace
(point.x);
trace
(point.y);
//
point=lbl.globalToLocal(point);
//
trace(point.x);
//
trace(point.y);
point=canvas.globalToContent(point);
trace
(point.x);
trace
(point.y);
//
point=canvas.globalToLocal(point);
//
trace(point.x);
//
trace(point.y);
}
]]>
</mx:Script>
<mx:Button
click = "showSupportingArea()" label = "
Test
"
/>
<mx:VDividedBox
id = "
vbox
" y = "
80
" height = "
500
" width =
"
100%
"
>
<mx:Canvas
id = "
canvas
" backgroundColor
= "
blue
" width = "
100%
" height = "
50%
"
>
<mx:Label
text = "
Hello
" id = "
lbl
" x = "
80
" y = "
300
"
/>
</mx:Canvas>
<mx:Canvas
id = "
support
"
backgroundColor = "
red
" width = "
100%
" height = "
0
"
/>
</mx:VDividedBox>
</mx:Application>
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"/@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{mso-style-parent:"";
margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
mso-pagination:none;
font-size:10.5pt;
mso-bidi-font-size:12.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:宋体;
mso-font-kerning:1.0pt;}
/* Page Definitions */
@page
{mso-page-border-surround-header:no;
mso-page-border-surround-footer:no;}
@page Section1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;
mso-header-margin:36.0pt;
mso-footer-margin:36.0pt;
mso-paper-source:0;}
div.Section1
{page:Section1;}
-->
注意:以下所有
global
,
local,content
坐标都是针对于上面这个组件而言的。
以上面这个组件
(
组件一,
comp1)
这例
,
假如当前这个文档的这一页为舞台
,
那么这个组件的左上角在该页面的坐标就是该组件的
global
坐标
.
现在假设在组件一中还有一个组件
(
组件二,
comp2)
,那组件二左上角的坐标则是组件一的
content
的
content
坐标,表示的是
comp2
在
comp1
的
content
中的绝对位置。
Content
的坐标原点不一定是在组件的原点,而是在组件的
content
的左上角。因此如果在
comp1
中添加了
comp2
,而且
comp2
的
x
,
y
都是固定的,那么
comp2
的左上角的
content
坐标在
comp1
的
content
中是不会变的,但是
local
坐标可能会变。因为
local
坐标永远是相对于
comp1
的左上角而言的。
<?xml version =
"1.0" encoding = "utf-8"?>
<mx:Application
xmlns:mx = " http://www.adobe.com/2006/mxml "
layout = "
absolute
"
>
<mx:Script>
<![CDATA[
import
mx.containers.Canvas;
private
function
showSupportingArea():
void
{
support.height=200;
var
point:Point=
new
Point();
//
point.x = lbl.x;
//
point.y = lbl.y;
//
point =
lbl.localToContent(point);
//
trace(point.x);trace(point.y);
//
point=lbl.contentToGlobal(point);
//
trace(point.x);
//
trace(point.y);
point=lbl.localToGlobal(point);
trace
(point.x);
trace
(point.y);
//
point=lbl.globalToLocal(point);
//
trace(point.x);
//
trace(point.y);
point=canvas.globalToContent(point);
trace
(point.x);
trace
(point.y);
//
point=canvas.globalToLocal(point);
//
trace(point.x);
//
trace(point.y);
}
]]>
</mx:Script>
<mx:Button
click = "showSupportingArea()" label = "
Test
"
/>
<mx:VDividedBox
id = "
vbox
" y = "
80
" height = "
500
" width =
"
100%
"
>
<mx:Canvas
id = "
canvas
" backgroundColor
= "
blue
" width = "
100%
" height = "
50%
"
>
<mx:Label
text = "
Hello
" id = "
lbl
" x = "
80
" y = "
300
"
/>
</mx:Canvas>
<mx:Canvas
id = "
support
"
backgroundColor = "
red
" width = "
100%
" height = "
0
"
/>
</mx:VDividedBox>
</mx:Application>
相关文章推荐
- [转]分析localToGlobal()和globalToLocal()
- 白鹭引擎 - 本地坐标和舞台坐标的转化 ( globalToLocal, localToGlobal )
- [转]分析localToGlobal()和globalToLocal()
- AS:分析localToGlobal()和globalToLocal()
- 转:Flex中的Image屬性 (width, contentWidth, content.width)的差異
- CorePlot学习 坐标轴的详细分析
- 安卓复杂滑动案例 自定义behavior源码分析 实现头布局图片的缩放透明度变化,RecycleView的滑动布局,坐标变化
- 索引分区分为:本地(局部)索引(local index) 全局索引(global index)
- CNI IPAM插件分析 --- 以hostlocal为示例
- 【phpcms-v9】content_form.calss.php文件分析-内容添加页面动态表单的生成原理
- 姿态论文整理--04-Human pose estimation using global and local normalization
- 线程本地存储(Thread Local Storage, TLS)简单分析与使用
- Android中将布局文件/View添加至窗口过程分析 ---- 从setContentView()谈起
- Flex示例:PopUpManager在全局坐标中心弹出窗口
- ThreadLocal 及InheritableThreadLocal 源码分析
- Local & Global
- python 局部local和全局global变量
- TabActivity,LocalActivityManager,TabHost,TabWidget深度分析(二)
- flex tomcat端口被占用的问题分析及解决方法
- Flex 应用内存泄露的分析与诊断