| 包 | mx.graphics |
| 类 | public class LinearGradient |
| 继承 | LinearGradient GradientBase EventDispatcher Object |
| 实现 | IFill |
| 语言版本: | ActionScript 3.0 |
| 产品版本: | Flex 3 |
| 运行时版本: | Flash Player 9, AIR 1.1 |
entries Array 中,以定义组成渐变填充的颜色。
在 MXML 中,您可以通过添加一系列 GradientEntry 对象来定义 LinearGradient,如以下示例所示:
<mx:fill> <mx:LinearGradient> <mx:entries> <mx:GradientEntry color="0xC5C551" ratio="0.00" alpha="0.5"/> <mx:GradientEntry color="0xFEFE24" ratio="0.33" alpha="0.5"/> <mx:GradientEntry color="0xECEC21" ratio="0.66" alpha="0.5"/> </mx:entries> </mx:LinearGradient> </mx:fill>
在 ActionScript 中,您还可以将 LinearGradient 定义为任何图形元素的填充,如以下示例所示:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()">
<mx:Script>
import flash.display.Graphics;
import flash.geom.Rectangle;
import mx.graphics.GradientEntry;
import mx.graphics.LinearGradient;
private function init():void
{
var w:Number = 200;
var h:Number = 200;
var s:Sprite = new Sprite();
// Add the new Sprite to the display list.
rawChildren.addChild(s);
var g:Graphics = s.graphics;
g.lineStyle(1, 0x33CCFF, 1.0);
var fill:LinearGradient = new LinearGradient();
var g1:GradientEntry = new GradientEntry(0xFFCC66, 0.00, 0.5);
var g2:GradientEntry = new GradientEntry(0x000000, 0.33, 0.5);
var g3:GradientEntry = new GradientEntry(0x99FF33, 0.66, 0.5);
fill.entries = [ g1, g2, g3 ];
fill.angle = 240;
// Draw a box and fill it with the LinearGradient.
g.moveTo(0, 0);
fill.begin(g, new Rectangle(0, 0, w, h));
g.lineTo(w, 0);
g.lineTo(w, h);
g.lineTo(0, h);
g.lineTo(0, 0);
fill.end(g);
}
</mx:Script>
</mx:Application>
MXML 语法
隐藏 MXML 语法The <mx:LinearGradient> tag
inherits all the tag attributes of its superclass,
and adds the following tag attributes:
<mx:LinearGradient
Properties
angle="0"
/>
默认 MXML 属性entries
相关 API 元素
公共属性
| 属性 | 由以下参数定义 | ||
|---|---|---|---|
![]() | angle : Number 不推荐使用: 请使用 rotation
默认情况下,LinearGradientStroke 定义控件进行从左到右的过渡。 | GradientBase | |
![]() | constructor : Object
对类对象或给定对象实例的构造函数的引用。 | Object | |
![]() | entries : Array
GradientEntry 对象 Array,用于定义渐变填充的填充模式。 | GradientBase | |
![]() | interpolationMethod : String
InterpolationMethod 类中的一个值,指定要使用的 interpolation 方法。 | GradientBase | |
![]() | matrix : Matrix
用于矩阵转换的值的数组。 | GradientBase | |
![]() | rotation : Number
默认情况下,LinearGradientStroke 定义控件进行从左到右的过渡。 | GradientBase | |
| scaleX : Number
渐变转换的水平缩放,用于定义(未旋转)渐变的宽度
| LinearGradient | ||
![]() | spreadMethod : String
SpreadMethod 类中用于指定要使用的扩展方法的值。 | GradientBase | |
![]() | x : Number
沿 x 轴平移每个点的距离。 | GradientBase | |
![]() | y : Number
沿 y 轴平移每个点的距离。 | GradientBase | |
受保护的属性
公共方法
| 方法 | 由以下参数定义 | ||
|---|---|---|---|
构造函数。 | LinearGradient | ||
![]() | addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。 | EventDispatcher | |
开始填充。 | LinearGradient | ||
![]() |
将事件调度到事件流中。 | EventDispatcher | |
结束填充。 | LinearGradient | ||
![]() |
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。 | EventDispatcher | |
![]() |
表示对象是否已经定义了指定的属性。 | Object | |
![]() |
表示 Object 类的实例是否在指定为参数的对象的原型链中。 | Object | |
![]() |
表示指定的属性是否存在、是否可枚举。 | Object | |
![]() |
从 EventDispatcher 对象中删除侦听器。 | EventDispatcher | |
![]() |
设置循环操作动态属性的可用性。 | Object | |
![]() |
返回此对象的字符串表示形式,其格式设置遵守区域设置特定的约定。 | Object | |
![]() |
返回指定对象的字符串表示形式。 | Object | |
![]() |
返回指定对象的原始值。 | Object | |
![]() |
检查是否用此 EventDispatcher 对象或其任何祖代为指定事件类型注册了事件侦听器。 | EventDispatcher | |
属性详细信息
scaleX | 属性 |
构造函数详细信息
LinearGradient | () | 构造函数 |
public function LinearGradient()| 语言版本: | ActionScript 3.0 |
| 产品版本: | Flex 3 |
| 运行时版本: | Flash Player 9, AIR 1.1 |
构造函数。
方法详细信息
begin | () | 方法 |
public function begin(target:Graphics, targetBounds:Rectangle, targetOrigin:Point):void| 语言版本: | ActionScript 3.0 |
| 产品版本: | Flex 3 |
| 运行时版本: | Flash Player 9, AIR 1.1 |
开始填充。
参数
target:Graphics — 要填充的目标 Graphics 对象。
| |
targetBounds:Rectangle — 定义 target 内填充大小的 Rectangle 对象。如果 Rectangle 的尺寸大于 target 的尺寸,则将剪裁填充。如果 Rectangle 的尺寸小于 target 的尺寸,则将扩展填充以填充整个 target。
| |
targetOrigin:Point — 在目标的坐标系中定义形状的原点 (0,0) 的点。
|
end | () | 方法 |
Tue Jun 12 2018, 11:04 AM Z
显示 MXML 语法