套件 | mx.graphics |
類別 | public class LinearGradient |
繼承 | LinearGradient GradientBase EventDispatcher Object |
實作 | IFill |
語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
entries
Array
to define the colors that make up the gradient fill.
In MXML, you define a LinearGradient by adding a series of GradientEntry objects, as the following example shows:
<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>
You can also define a LinearGradient as a fill for any graphic element in ActionScript, as the following example shows:
<?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
By default, the LinearGradientStroke defines a transition
from left to right across the control. | GradientBase | ||
constructor : Object
類別物件的參照或是特定物件實體的建構函數。 | Object | ||
entries : Array
An Array of GradientEntry objects
defining the fill patterns for the gradient fill. | GradientBase | ||
interpolationMethod : String
A value from the InterpolationMethod class
that specifies which interpolation method to use. | GradientBase | ||
matrix : Matrix
An array of values used for matrix transformation. | GradientBase | ||
rotation : Number
By default, the LinearGradientStroke defines a transition
from left to right across the control. | GradientBase | ||
scaleX : Number
The horizontal scale of the gradient transform, which defines the width of the (unrotated) gradient
| LinearGradient | ||
spreadMethod : String
A value from the SpreadMethod class
that specifies which spread method to use. | GradientBase | ||
x : Number
The distance by which to translate each point along the x axis. | GradientBase | ||
y : Number
The distance by which to translate each point along the y axis. | GradientBase |
公用方法
方法 | 定義自 | ||
---|---|---|---|
Constructor. | LinearGradient | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。 | EventDispatcher | ||
Starts the fill. | LinearGradient | ||
會將事件傳送到事件流程。 | EventDispatcher | ||
Ends the fill. | LinearGradient | ||
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。 | EventDispatcher | ||
指出物件是否有已定義的指定屬性。 | Object | ||
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。 | Object | ||
指出指定的屬性是否存在,以及是否可列舉。 | Object | ||
會從 EventDispatcher 物件移除偵聽程式。 | EventDispatcher | ||
為迴圈作業設定動態屬性的可用性。 | Object | ||
傳回代表此物件的字串,根據地區特定慣例進行格式化。 | Object | ||
會傳回指定之物件的字串形式。 | Object | ||
會傳回指定之物件的基本值。 | Object | ||
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。 | EventDispatcher |
屬性詳細資訊
scaleX | 屬性 |
scaleX:Number
語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
The horizontal scale of the gradient transform, which defines the width of the (unrotated) gradient
此屬性可以做為資料繫結的來源。一旦修改此屬性,將傳送 propertyChange
事件。
實作
public function get scaleX():Number
public function set scaleX(value:Number):void
建構函式詳細資料
LinearGradient | () | 建構函式 |
public function LinearGradient()
語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
Constructor.
方法詳細資訊
begin | () | 方法 |
public function begin(target:Graphics, targetBounds:Rectangle, targetOrigin:Point):void
語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
Starts the fill.
參數
target:Graphics — The target Graphics object that is being filled.
| |
targetBounds:Rectangle — The Rectangle object that defines the size of the fill
inside the target .
If the dimensions of the Rectangle are larger than the dimensions
of the target , the fill is clipped.
If the dimensions of the Rectangle are smaller than the dimensions
of the target , the fill expands to fill the entire
target .
| |
targetOrigin:Point — The Point that defines the origin (0,0) of the shape in the
coordinate system of target.
|
end | () | 方法 |
Tue Jun 12 2018, 03:47 PM Z