Group 类是可视元素的容器基类。Group 容器将实现 IUIComponent 接口的任何组件和实现 IGraphicElement 接口的任何组件视为子代。希望管理可视子项(可视组件和图形组件)时,使用此容器。
为了改进性能和最小化应用程序大小,不能设置 Group 容器的外观。如果希望应用外观,请改用 SkinnableContainer。
注意:当 Group 内部存在 DisplayObject 子代(如组件或另一个 Group)时,刻度网格可能无法正常工作。如果子代是 GraphicElement 对象,并且全部共享该 Group 的 DisplayObject,则刻度网格将正常工作。
对 GraphicElement 子代设置下列任何属性要求 GraphicElement 创建其自己的 DisplayObject,从而使 Group 的刻度网格属性无效。
alpha blendMode other than BlendMode.NORMAL or "auto" colorTransform filters mask matrix rotation scaling 3D properties bounds outside the extent of the Group
Group 容器具有下列默认特征:
隐藏 MXML 语法
The <s:Group> tag inherits all of the tag
attributes of its superclass and adds the following tag attributes:
<s:Group
Properties
blendMode="auto"
mxmlContent="null"
scaleGridBottom="null"
scaleGridLeft="null"
scaleGridRight="null"
scaleGridTop="null"
Events
elementAdd="No default"
elementRemove="No default"
/>
mxmlContent
查看示例
样式为常见样式,或与特定主题关联。如果为常见样式,则可以用于任何主题。如果样式与特定主题关联,则只有应用程序使用该主题时才能使用该样式。
语言版本: ActionScript 3.0
产品版本: Flex 4.5
运行时版本: Flash10.1, AIR 2.5
按下项呈示器时其背景的颜色
如果 downColor 设置为 undefined,将不使用 downColor.
语言版本: ActionScript 3.0
产品版本: Flex 4
运行时版本: Flash10, AIR 1.5
文本阴影的 Alpha。
默认值为 0.55。
语言版本: ActionScript 3.0
产品版本: Flex 4
运行时版本: Flash10, AIR 1.5
文本阴影的颜色。
默认值为 #FFFFFF。
baselinePosition:Number [只读] [覆盖]
组件第一行文本的基线的 y 坐标。
此属性用于实现 baseline 约束样式,还可用于将 FormItem 的标签与 FormItem 中的控件对齐。
各组件应覆盖此属性。
override public function get baselinePosition():Number
baselinePositionElement:IVisualElement
用于计算 GroupBase 的 baselinePosition 的元素
public function get baselinePositionElement():IVisualElement public function set baselinePositionElement(value:IVisualElement):void
blendMode:String[覆盖]
BlendMode 类中的一个值,用于指定要使用的混合模式。 内部绘制位图的方法有两种。如果启用了混合模式或外部剪辑遮罩,则将通过向矢量渲染器添加有位图填充的正方形来绘制位图。 如果尝试将此属性设置为无效值,则 Flash Player 或 Adobe AIR 会将该值设置为 BlendMode.NORMAL。
“auto”值(默认值)特定于 blendMode 的 Group 使用情况,并指明基础 blendMode 应为 BlendMode.NORMAL,但以下情况除外,即 alpha 不等于 0 或 1 时,此时 blendMode 设置为 BlendMode.LAYER。该行为可确保,当组为半透明时,各组中相应图形对象的合成正确无误。
默认值为 "auto"。
override public function get blendMode():String override public function set blendMode(value:String):void
mxmlContent:Array [只写]
此 Group 的可视内容子项。此方法供 Flex 内部使用,不适合由开发人员直接使用。
内容项目仅应该是 IVisualElement 对象。因为可视元素一次仅可以处于一个容器中,所以不应该在多个 Group 容器之间共享 mxmlContent Array。
如果内容是一个 Array,不要直接修改该 Array。请改用由 Group 类定义的方法。
默认值为 null。
public function set mxmlContent(value:Array):void
scaleGridBottom:Number
指定刻度网格的底部坐标。
public function get scaleGridBottom():Number public function set scaleGridBottom(value:Number):void
scaleGridLeft:Number
指定刻度网格的左侧坐标。
public function get scaleGridLeft():Number public function set scaleGridLeft(value:Number):void
scaleGridRight:Number
指定刻度网格的右侧坐标。
public function get scaleGridRight():Number public function set scaleGridRight(value:Number):void
scaleGridTop:Number
指定刻度网格的顶部坐标。
public function get scaleGridTop():Number public function set scaleGridTop(value:Number):void
public function addElement(element:IVisualElement):IVisualElement
将可视元素添加到此容器中。该元素将在添加完所有其他元素之后添加,并出现于所有其他元素之上。要将可视元素添加到特定索引位置,请使用 addElementAt() 方法。
如果添加的可视元素已有一个不同的容器作为父项,则该元素将会从其他容器中删除。
:IVisualElement — 要添加为此容器的子项的可视元素。
IVisualElement — 已添加的元素。
public function addElementAt(element:IVisualElement, index:int):IVisualElement
将可视元素添加到此容器中。该元素将被添加到指定的索引位置。索引 0 代表显示列表中的第一个元素。
如果添加的可视元素已有一个不同的容器作为父项,则该元素将会从其他容器中删除。
:IVisualElement — 要添加为此可视容器的子项的元素。
:int — 将该元素添加到的索引位置。如果指定当前占用的索引位置,则该位置以及所有更高位置上的子对象会在子级列表中上移一个位置。
IVisualElement — 已添加的元素。
public function invalidateGraphicElementDisplayList(element:IGraphicElement):void
请注意元素已更改且需要重新绘制的主机组件。Group 对 IGraphicElement 调用 validateDisplayList() 方法,为其赋予重新绘制的机会。
:IGraphicElement — 已更改的元素。
public function invalidateGraphicElementProperties(element:IGraphicElement):void
请注意元素已更改且需要验证属性的主机组件。Group 对 IGraphicElement 调用 validateProperties() 方法,为其赋予提交其属性的机会。
:IGraphicElement — 已更改的元素。
public function invalidateGraphicElementSharing(element:IGraphicElement):void
请注意元素图层已更改的主机。Group 使用共享的 DisplayObject 重新评估元素的序列,且可能会重新分配 DisplayObject,并因此重新绘制这些序列。
:IGraphicElement — 已更改大小的元素。
public function invalidateGraphicElementSize(element:IGraphicElement):void
请注意元素大小已更改的主机组件。Group 对 IGraphicElement 调用 validateSize() 方法,为其赋予验证其大小的机会。
:IGraphicElement — 已更改大小的元素。
public function removeAllElements():void
从容器中删除所有可视元素。
public function removeElement(element:IVisualElement):IVisualElement
从此容器的子列表中删除指定的可视元素。在该可视容器中,位于该元素之上的所有元素的索引位置都减少 1。
:IVisualElement — 要从容器中删除的元素。
IVisualElement — 已删除的元素。
public function removeElementAt(index:int):IVisualElement
从容器中的指定索引位置删除可视元素。在该可视容器中,位于该元素之上的所有元素的索引位置都减少 1。
:int — 要删除的元素的索引。
IVisualElement — 已删除的元素。
public function setElementIndex(element:IVisualElement, index:int):void
在可视容器中更改现有可视元素的位置。
在调用 setElementIndex() 方法并指定一个已经占用的索引位置时,只有元素的先前位置和新位置之间的位置发生更改。其他位置保持不变。
如果将某个可视元素移动到低于其当前索引位置的某个索引位置,则在这两个索引之间的所有元素的索引都增加 1。如果将某个元素移动到高于其当前索引位置的某个索引位置,则在这两个索引之间的所有元素的索引都减少 1。
:IVisualElement — 要为其更改索引编号的元素。
:int — 元素的最终索引编号。
public function swapElements(element1:IVisualElement, element2:IVisualElement):void
交换两个指定可视元素的索引。所有其他元素仍位于相同的索引位置。
:IVisualElement — 第一个可视元素。
:IVisualElement — 第二个可视元素。
public function swapElementsAt(index1:int, index2:int):void
交换容器中位于两个指定索引位置的可视元素。所有其他可视元素仍位于相同的索引位置。
:int — 第一个元素的索引。
:int — 第二个元素的索引。
spark.events.ElementExistenceEventspark.events.ElementExistenceEvent.ELEMENT_ADD
将可视元素添加到内容容器时调度。event.element 是已添加的可视元素。
ElementExistenceEvent.ELEMENT_ADD 常量可为 elementAdd 事件定义事件对象的 type 属性值。
事件对象的属性有下列值:
bubblescancelablecurrentTargetmyButton.addEventListener() 注册某个事件侦听器,则 myButton 为 currentTarget 的值。 elementindextargetcurrentTarget 属性始终可以访问侦听事件的 Object。spark.events.ElementExistenceEventspark.events.ElementExistenceEvent.ELEMENT_REMOVE
从内容容器中删除可视元素时调度。event.element 是正在删除的可视元素。
ElementExistenceEvent.ELEMENT_REMOVE 常量可为 elementRemove 事件定义事件对象的 type 属性值。
事件对象的属性有下列值:
bubblescancelablecurrentTargetmyButton.addEventListener() 注册某个事件侦听器,则 myButton 为 currentTarget 的值。 elementindextargetcurrentTarget 属性始终可以访问侦听事件的 Object。<?xml version="1.0"?>
<!-- Simple example to demonstrate the Spark Group component. -->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" >
<s:Panel title="Group Component Example"
width="75%" height="75%"
horizontalCenter="0" verticalCenter="0">
<s:VGroup left="10" right="10" top="10" bottom="10">
<s:Group>
<!-- use a vertical layout with a 1 pixel gap between items -->
<s:layout>
<s:VerticalLayout gap="1" />
</s:layout>
<s:Label text="Group with a vertical layout" />
<s:Rect width="150" height="20">
<s:fill>
<s:SolidColor color="0xE3E3E3" />
</s:fill>
</s:Rect>
<s:Rect width="150" height="20">
<s:fill>
<s:SolidColor color="0xCCCCCC" />
</s:fill>
</s:Rect>
<s:Rect width="150" height="20">
<s:fill>
<s:SolidColor color="0x888888" />
</s:fill>
</s:Rect>
</s:Group>
<mx:Spacer height="20" />
<s:Group>
<!-- use a horizontal layout with a 1 pixel gap between items -->
<s:layout>
<s:HorizontalLayout gap="1" />
</s:layout>
<s:Label text="Group with a horizontal layout" />
<s:Rect width="25" height="25">
<s:fill>
<s:SolidColor color="0xE3E3E3" />
</s:fill>
</s:Rect>
<s:Rect width="25" height="25">
<s:fill>
<s:SolidColor color="0xCCCCCC" />
</s:fill>
</s:Rect>
<s:Rect width="25" height="25">
<s:fill>
<s:SolidColor color="0x888888" />
</s:fill>
</s:Rect>
</s:Group>
<mx:Spacer height="20" />
<s:Group width="150" height="100">
<!-- use the default basic layout where items are absolutely positioned -->
<!-- add a background rectangle to stretch to fit the group -->
<s:Rect top="0" left="0" right="0" bottom="0">
<s:fill>
<s:SolidColor color="0xCCCCCC" />
</s:fill>
</s:Rect>
<s:Label x="0" y="0" text="Group with a basic layout" />
<s:Rect x="20" y="20" width="30" height="25">
<s:fill>
<s:SolidColor color="0xE3E3E3" />
</s:fill>
</s:Rect>
<s:Rect x="40" y="40" width="30" height="30">
<s:fill>
<s:SolidColor color="0x888888" />
</s:fill>
</s:Rect>
<s:Rect x="60" y="60" width="30" height="30">
<s:fill>
<s:SolidColor color="0xBBBBBB" />
</s:fill>
</s:Rect>
</s:Group>
</s:VGroup>
</s:Panel>
</s:Application>
显示 MXML 语法










