| 包 | spark.primitives | 
| 类 | public class Line | 
| 继承 | Line    StrokedElement   GraphicElement   EventDispatcher   Object | 
| 语言版本: | ActionScript 3.0 | 
| 产品版本: | Flex 4 | 
| 运行时版本: | Flash Player 10, AIR 1.5 | 
未定义直线的默认笔触;因此,如果未指定笔触,则该直线不可见。
相关 API 元素
| 方法 | 由以下参数定义 | ||
|---|---|---|---|
Line() 
      构造函数。  | Line | ||
![]()  | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void 
	使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。  | EventDispatcher | |
![]()  | 
      
      如果此 IGraphicElement 是兼容的且可以与序列中下一个 IGraphicElement 共享显示对象,则返回 true。  | GraphicElement | |
![]()  | 
      
      如果此 IGraphicElement 是兼容的且可以与序列中上一个 IGraphicElement 共享显示对象,则返回 true。  | GraphicElement | |
![]()  | 
      
      创建一个新 DisplayObject 以用于绘制此 IGraphicElement。  | GraphicElement | |
![]()  | 
	将事件调度到事件流中。  | EventDispatcher | |
![]()  | 
      
      按指定的元素大小,返回元素边界的 x 坐标。  | GraphicElement | |
![]()  | 
      
      按指定的元素大小,返回元素边界的 y 坐标。  | GraphicElement | |
![]()  | 
      
      返回元素的布局高度。  | GraphicElement | |
![]()  | 
      
      返回元素的布局宽度。  | GraphicElement | |
![]()  | 
      
      返回元素在屏幕上进行绘制时所用的 x 坐标。  | GraphicElement | |
![]()  | 
      
      返回元素在屏幕上进行绘制时所用的 y 坐标。  | GraphicElement | |
![]()  | 
      
      返回用于相对于其同级组件计算组件的布局的转换矩阵。  | GraphicElement | |
![]()  | 
      
      返回此元素的布局转换 Matrix3D。  | GraphicElement | |
![]()  | 
      
      返回元素的最大高度。  | GraphicElement | |
![]()  | 
      
      返回元素的最大宽度。  | GraphicElement | |
![]()  | 
      
      返回元素的最小高度。  | GraphicElement | |
![]()  | 
      
      返回元素的最小宽度。  | GraphicElement | |
![]()  | 
      
      返回元素的首选高度。  | GraphicElement | |
![]()  | 
      
      返回元素的首选宽度。  | GraphicElement | |
![]()  | 
	检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。  | EventDispatcher | |
![]()  | 
	 表示对象是否已经定义了指定的属性。  | Object | |
![]()  | 
      如果 GraphicElement 是使用 MXML 标签创建的,则由 MXML 编译器自动调用。  | GraphicElement | |
![]()  | 
      调用此方法将导致在呈示显示列表前调用元素的 validateDisplayList() 方法。  | GraphicElement | |
![]()  | 
     
          当某元素的 layoutDirection 更改或其父代的 layoutDirection 更改时,该元素必须调用该方法。  | GraphicElement | |
![]()  | 
      调用此方法将导致在呈示显示列表前调用元素的 validateProperties() 方法。  | GraphicElement | |
![]()  | 
      调用此方法将导致在呈示显示列表前调用元素的 validateSize() 方法。  | GraphicElement | |
![]()  | 
	 表示 Object 类的实例是否在指定为参数的对象的原型链中。  | Object | |
![]()  | 
     将 Point 对象从对象的(局部)坐标转换为舞台(全局)坐标。  | GraphicElement | |
![]()  | 
      
      将 IGraphicElement 添加到主机组件或从主机组件将其删除时由 IGraphicElementContainer 调用。  | GraphicElement | |
![]()  | 
	 表示指定的属性是否存在、是否可枚举。  | Object | |
![]()  | 
	从 EventDispatcher 对象中删除侦听器。  | EventDispatcher | |
![]()  | setLayoutBoundsPosition(newBoundsX:Number, newBoundsY:Number, postLayoutTransform:Boolean = true):void 
      
      设置元素在屏幕上进行绘制时所用的坐标。  | GraphicElement | |
![]()  | 
      
      设置元素的布局大小。  | GraphicElement | |
![]()  | 
      
      设置用于相对于其同级组件计算组件的布局大小和位置的转换 Matrix。  | GraphicElement | |
![]()  | 
      
      设置用于计算组件相对于其同级组件的布局大小和位置的转换 Matrix3D。  | GraphicElement | |
![]()  | 
     设置循环操作动态属性的可用性。  | Object | |
![]()  | 
      
      确定此元素是否可以将它自己绘制到该序列的 sharedDisplayObject。  | GraphicElement | |
![]()  | 
	 返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。  | Object | |
![]()  | 
	 返回指定对象的字符串表示形式。  | Object | |
![]()  | transformAround(transformCenter:Vector3D, scale:Vector3D = null, rotation:Vector3D = null, translation:Vector3D = null, postLayoutScale:Vector3D = null, postLayoutRotation:Vector3D = null, postLayoutTranslation:Vector3D = null, invalidateLayout:Boolean = true):void 
      用于更新转换的旋转、缩放和平移的一种实用程序方法,同时保留某个特定点,该点是在组件自己的坐标空间中指定的,且在父项的坐标空间中是固定的。  | GraphicElement | |
![]()  | 
     一种实用程序方法,用于将以该对象的本地坐标指定的点转换为在该对象父坐标中的相应位置。  | GraphicElement | |
![]()  | 
      
      由 IGraphicElementContainer 调用以在其 displayObject 属性中重新绘制此元素。  | GraphicElement | |
![]()  | 
      根据需要,通过立即调用 validateProperties()、validateSize() 和 validateDisplayList() 来验证并更新此对象的属性和布局。  | GraphicElement | |
![]()  | 
      由布局逻辑用于通过调用 commitProperties() 方法来验证组件的属性。  | GraphicElement | |
![]()  | 
      
      由 IGraphicElementContainer 调用以验证此元素的大小。  | GraphicElement | |
![]()  | 
	 返回指定对象的原始值。  | Object | |
![]()  | 
	检查是否用此 EventDispatcher 对象或其任何祖代为指定事件类型注册了事件侦听器。  | EventDispatcher | |
| 方法 | 由以下参数定义 | ||
|---|---|---|---|
![]()  | 
      为此元素设置绘制。  | StrokedElement | |
[覆盖] 
      
      确定是否可以跳过对 measure() 方法的调用。  | Line | ||
![]()  | 
      处理在元素上设置的属性。  | GraphicElement | |
[覆盖] 
      
      绘制元素。  | Line | ||
![]()  | 
      完成此元素的绘制。  | StrokedElement | |
![]()  | 
      返回元素界限每一侧上的笔触所占据的像素数。  | GraphicElement | |
![]()  | 
      通知主机此元素已更改且需要更新其图层的实用程序方法。  | GraphicElement | |
![]()  | 
      此对象影响其布局时(includeInLayout 为 true),使父代大小和显示列表失效的 Helper 方法。  | GraphicElement | |
[覆盖] 
      
      计算元素的默认大小。  | Line | ||
![]()  | 
      用于 ILayoutElement 接口的实现,返回显式度量的高度预转换。  | GraphicElement | |
![]()  | 
      用于 ILayoutElement 接口的实现,返回测量宽度预转换的显式。  | GraphicElement | |
![]()  | 
      转换元素的大小。  | GraphicElement | |
![]()  | 
      转换元素的大小。  | GraphicElement | |
![]()  | [覆盖] 
      
      绘制元素和/或调整其内容的大小并定位该内容。  | StrokedElement | |
xFrom | 属性 | 
xTo | 属性 | 
yFrom | 属性 | 
yTo | 属性 | 
Line | () | 构造函数 | 
public function Line()| 语言版本: | ActionScript 3.0 | 
| 产品版本: | Flex 4 | 
| 运行时版本: | Flash Player 10, AIR 1.5 | 
构造函数。
canSkipMeasurement | () | 方法 | 
draw | () | 方法 | 
measure | () | 方法 | 
override protected function measure():void| 语言版本: | ActionScript 3.0 | 
| 产品版本: | Flex 4 | 
| 运行时版本: | Flash Player 10, AIR 1.5 | 
计算元素的默认大小。此方法是一种高级方法,可在创建 GraphicElement 的子类时覆盖。
您无需直接调用此方法。使用 addElement() 方法将元素添加到 IGraphicElementContainer 容器(例如,组)时,以及调用元素的 invalidateSize() 方法时,Flex 会调用 measure() 方法。 
默认情况下您会设置元素的显式高度和显式宽度,Flex 不会调用 measure() 方法,即使您显式调用 invalidateSize() 方法也不例外。若要覆盖此行为,请覆盖 skipMeasure() 方法。
覆盖此方法时,必须设置 measuredWidth 和 measuredHeight 属性以定义默认大小。您可以选择设置 measuredX 和 measuredY 属性以定义相对于元素的原点的默认测量界限左上角。
measure() 的概念点供元素提供其自己的原始或固有界限作为默认值。因此,measuredWidth 和 measuredHeight 属性应由以下几个因素确定:
- 组件需要显示的文本量。
 - 组件所显示的 JPEG 图像的大小。
 
某些情况下,确定默认值的方式并不固定。例如,对于一个简单的 GreenCircle 元素,可能只需在其 measure() 方法中设置 measuredWidth = 100 和 measuredHeight = 100 便可提供合理的默认大小。而在其他情况下(例如 TextArea),相应计算(例如查找合适的宽度和高度,使其刚好适合显示所有文本并拥有黄金矩形的高宽比)所耗费的时间可能会过长。
measure() 的默认实现会将 measuredWidth、measuredHeight、measuredX 和 measuredY 属性的值设置为 0。
<?xml version="1.0" encoding="utf-8"?>
<!-- examples/LineExample.mxml -->
<s:Application 
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:mx="library://ns.adobe.com/flex/mx" 
    xmlns:s="library://ns.adobe.com/flex/spark">
     <mx:Panel title="Line MXML Graphic Example"
        height="75%" width="75%" layout="horizontal"
        paddingTop="30" paddingBottom="10" paddingLeft="10" paddingRight="10">
        <s:Group x="20" y="20">
            <s:Line xFrom="0" xTo="0" yFrom="0" yTo="100">
                 <!-- Define the border color of the line. -->
                 <s:stroke>
                      <s:SolidColorStroke color="0x000000" weight="1" caps="square"/>
                 </s:stroke>
            </s:Line>
            <s:Line xFrom="6" xTo="6" yFrom="0" yTo="100">
                 <s:stroke>
                      <s:SolidColorStroke color="0x000000" weight="1" caps="square"/>
                 </s:stroke>
            </s:Line>
            <s:Line xFrom="12" xTo="12" yFrom="0" yTo="100">
                 <s:stroke>
                      <s:SolidColorStroke color="0x000000" weight="2" caps="square"/>
                 </s:stroke>
            </s:Line>
            <s:Line xFrom="20" xTo="20" yFrom="0" yTo="100">
                 <s:stroke>
                      <s:SolidColorStroke color="0x000000" weight="3" caps="square"/>
                 </s:stroke>
            </s:Line>
            <s:Line xFrom="30" xTo="30" yFrom="0" yTo="100">
                 <s:stroke>
                      <s:SolidColorStroke color="0x000000" weight="5" caps="square"/>
                 </s:stroke>
            </s:Line>
            <s:Line xFrom="43" xTo="43" yFrom="0" yTo="100">
                 <s:stroke>
                      <s:SolidColorStroke color="0x000000" weight="8" caps="square"/>
                 </s:stroke>
            </s:Line>
            <s:Line xFrom="58" xTo="58" yFrom="0" yTo="100">
                 <s:stroke>
                      <s:SolidColorStroke color="0x000000" weight="13" caps="square"/>
                 </s:stroke>
            </s:Line>
            <s:Line xFrom="84" xTo="84" yFrom="0" yTo="100">
                 <s:stroke>
                      <s:SolidColorStroke color="0x000000" weight="21" caps="square"/>
                 </s:stroke>
            </s:Line>
            <s:Line xFrom="123" xTo="123" yFrom="0" yTo="100">
                 <s:stroke>
                      <s:SolidColorStroke color="0x000000" weight="34" caps="square"/>
                 </s:stroke>
            </s:Line>
        </s:Group>
     </mx:Panel>
</s:Application>
Tue Jun 12 2018, 11:04 AM Z
 
 隐藏继承的公共属性
 显示继承的公共属性