套件 | mx.core |
類別 | public class SpriteAsset |
繼承 | SpriteAsset FlexSprite Sprite DisplayObjectContainer InteractiveObject DisplayObject EventDispatcher Object |
實作 | IFlexAsset, IFlexDisplayObject, IBorder, ILayoutDirectionElement |
子類別 | DefaultDragImage |
語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
The vector graphic image that you're embedding can be in an SVG file. You can also embed a sprite symbol that is in a SWF file produced by Flash. In both cases, the MXML compiler autogenerates a class that extends SpriteAsset to represent the embedded vector graphic image.
You don't generally have to use the SpriteAsset class directly when you write a Flex application. For example, you can embed a sprite symbol from a SWF file and display it in an Image control by writing the following:
<mx:Image id="logo" source="@Embed(source='Assets.swf', symbol='Logo')"/>
Or use it as the application's background image in CSS syntax by writing the following:
<fx:Style> @namespace mx "library://ns.adobe.com/flex/mx" mx|Application { backgroundImage: Embed(source="Assets.swf", symbol='Logo') } <fx:Style/>
without having to understand that the MXML compiler has created a subclass of BitmapAsset for you.
However, it may be useful to understand what is happening
at the ActionScript level.
To embed a vector graphic image in ActionScript, you declare a variable
of type Class, and put [Embed]
metadata on it.
For example, you embed a sprite symbol from a SWF file like this:
[Bindable] [Embed(source="Assets.swf", symbol="Logo")] private var logoClass:Class;
The MXML compiler notices that the Logo symbol in Assets.swf
is a sprite, autogenerates a subclass of the SpriteAsset class
to represent it, and sets your variable to be a reference to this
autogenerated class.
You can then use this class reference to create instances of the
SpriteAsset using the new
operator, and use APIs
of the Sprite class on them:
var logo:SpriteAsset = SpriteAsset(new logoClass()); logo.rotation=45;
However, you rarely need to create SpriteAsset instances yourself
because image-related properties and styles can simply be set to an
image-producing class, and components will create image instances
as necessary.
For example, to display this vector graphic image in an Image control,
you can set the Image's source
property to
logoClass
.
In MXML you could do this as follows:
<mx:Image id="logo" source="{logoClass}"/>
屬性 | 定義自 | ||
---|---|---|---|
accessibilityImplementation : AccessibilityImplementation
對此 InteractiveObject 實體目前的輔助功能實作 (AccessibilityImplementation)。 | InteractiveObject | ||
accessibilityProperties : AccessibilityProperties
此顯示物件的目前輔助功能選項。 | DisplayObject | ||
alpha : Number
指出所指定物件的 Alpha 透明度值。 | DisplayObject | ||
blendMode : String
來自 BlendMode 類別的值,會指定要使用何種混合模式。 | DisplayObject | ||
blendShader : Shader [唯寫]
設定用來混合前景和背景的著色器。 | DisplayObject | ||
borderMetrics : EdgeMetrics [唯讀]
Returns an EdgeMetrics object for the border that has four properties:
left, top, right,
and bottom. | SpriteAsset | ||
buttonMode : Boolean
可指定此 sprite 的按鈕模式。 | Sprite | ||
cacheAsBitmap : Boolean
如果設定為 true,Flash 執行階段會快取顯示物件的內部點陣圖表示法。 | DisplayObject | ||
cacheAsBitmapMatrix : Matrix
如果為非 null,當 cacheAsBitmap 設定為 true 時,這個 Matrix 物件會定義顯示物件的顯示方法。 | DisplayObject | ||
constructor : Object
類別物件的參照或是特定物件實體的建構函數。 | Object | ||
contextMenu : NativeMenu
指定與此物件有關聯的快顯選單。 | InteractiveObject | ||
doubleClickEnabled : Boolean
會指定物件是否會收到 doubleClick 事件。 | InteractiveObject | ||
dropTarget : DisplayObject [唯讀]
指定要將 sprite 拖曳至或丟棄至哪個顯示物件上。 | Sprite | ||
filters : Array
索引的陣列,其中包含目前和顯示物件相關的每個濾鏡物件。 | DisplayObject | ||
focusRect : Object
會指定這個物件是否會顯示焦點矩形。 | InteractiveObject | ||
graphics : Graphics [唯讀]
指定屬於此 sprite 物件的 Graphics 物件,其中可能會產生向量繪圖命令。 | Sprite | ||
height : Number
會指出顯示物件的高度,以像素為單位。 | DisplayObject | ||
hitArea : Sprite
指定用來當作 sprite 作用區域的另一個 sprite。 | Sprite | ||
layoutDirection : String
Specifies the desired layout direction for an element: one of LayoutDirection.LTR
(left to right), LayoutDirection.RTL (right to left), or null (inherit). | SpriteAsset | ||
loaderInfo : LoaderInfo [唯讀]
會傳回 LoaderInfo 物件,其中包含關於載入此顯示物件所屬之檔案的資訊。 | DisplayObject | ||
mask : DisplayObject
呼叫之顯示物件會以指定的 mask 物件遮蓋。 | DisplayObject | ||
measuredHeight : Number [唯讀]
The measured height of this object. | SpriteAsset | ||
measuredWidth : Number [唯讀]
The measured width of this object. | SpriteAsset | ||
metaData : Object
如果中繼資料是透過 PlaceObject4 標籤與 SWF 檔案中的這個 DisplayObject 實體一同儲存,則會取得 DisplayObject 實體的中繼資料物件。 | DisplayObject | ||
mouseChildren : Boolean
判斷物件的子系是否支援啟用滑鼠或使用者輸入裝置。 | DisplayObjectContainer | ||
mouseEnabled : Boolean
指定此物件是否接收滑鼠或其他使用者輸入及訊息。 | InteractiveObject | ||
mouseX : Number [唯讀]
指出滑鼠或使用者輸入裝置位置的 x 座標,以像素為單位。 | DisplayObject | ||
mouseY : Number [唯讀]
指出滑鼠或使用者輸入裝置位置的 y 座標,以像素為單位。 | DisplayObject | ||
name : String
指出 DisplayObject 的實體名稱。 | DisplayObject | ||
needsSoftKeyboard : Boolean
指定虛擬鍵盤 (螢幕上的軟體鍵盤) 是否應在此 InteractiveObject 實體接收到焦點時顯示。 | InteractiveObject | ||
numChildren : int [唯讀]
傳回此物件的子系數量。 | DisplayObjectContainer | ||
opaqueBackground : Object
會指定顯示物件是否不透明,並具有特定背景顏色。 | DisplayObject | ||
parent : DisplayObjectContainer [唯讀]
指出包含此顯示物件的 DisplayObjectContainer 物件。 | DisplayObject | ||
root : DisplayObject [唯讀]
對載入之 SWF 檔案的顯示物件而言,root 屬性就是該 SWF 檔案所呈現之顯示清單樹狀結構部分的最上層顯示物件。 | DisplayObject | ||
rotation : Number
指出 DisplayObject 實體的旋轉度數 (從該物件原本方向算起)。 | DisplayObject | ||
rotationX : Number
表示 DisplayObject 實體相對於 3D 父輩容器從原始方向旋轉的 x 軸旋轉 (以度數為單位)。 | DisplayObject | ||
rotationY : Number
表示 DisplayObject 實體相對於 3D 父輩容器從原始方向旋轉的 y 軸旋轉 (以度數為單位)。 | DisplayObject | ||
rotationZ : Number
表示 DisplayObject 實體相對於 3D 父輩容器從原始方向旋轉的 z 軸旋轉 (以度數為單位)。 | DisplayObject | ||
scale9Grid : Rectangle
目前產生效用的縮放格線。 | DisplayObject | ||
scaleX : Number
指出從註冊點套用的物件水平縮放 (百分比)。 | DisplayObject | ||
scaleY : Number
指出從物件註冊點套用的物件垂直縮放 (百分比)。 | DisplayObject | ||
scaleZ : Number
指出從物件註冊點套用的物件深度縮放 (百分比)。 | DisplayObject | ||
scrollRect : Rectangle
顯示物件的捲動矩形範圍。 | DisplayObject | ||
softKeyboard : String
控制軟體鍵盤的外觀。 | InteractiveObject | ||
softKeyboardInputAreaOfInterest : Rectangle
定義顯示軟體鍵盤時,應保留於螢幕上的區域 (iOS 未提供)。 | InteractiveObject | ||
soundTransform : flash.media:SoundTransform
控制此 Sprite 的聲音。 | Sprite | ||
stage : Stage [唯讀]
顯示物件的「舞台」。 | DisplayObject | ||
tabChildren : Boolean
判斷物件的子系是否支援啟用定位鍵。 | DisplayObjectContainer | ||
tabEnabled : Boolean
會指定這個物件是否在停駐點順序中。 | InteractiveObject | ||
tabIndex : int
會指定 SWF 檔中的物件停駐點順序。 | InteractiveObject | ||
textSnapshot : flash.text:TextSnapshot [唯讀]
傳回此 DisplayObjectContainer 實體的 TextSnapshot 物件。 | DisplayObjectContainer | ||
transform : flash.geom:Transform
這是一個物件,具有和顯示物件的矩陣、顏色轉換和像素邊界有關的屬性。 | DisplayObject | ||
useHandCursor : Boolean
指示當指標滑入 Sprite,且其 buttonMode 屬性設為 true 時,是否要出現指示手掌 (手掌游標) 的 Boolean 值。 | Sprite | ||
visible : Boolean
不管是否看得見顯示物件。 | DisplayObject | ||
width : Number
會指出顯示物件的寬度,以像素為單位。 | DisplayObject | ||
x : Number
指出 DisplayObject 實體相對於父輩 DisplayObjectContainer 之區域座標的 x 座標。 | DisplayObject | ||
y : Number
指出 DisplayObject 實體相對於父輩 DisplayObjectContainer 之區域座標的 y 座標。 | DisplayObject | ||
z : Number
表示 DisplayObject 實體相對於 3D 父輩容器的 z 座標位置 (沿著 z 軸)。 | DisplayObject |
方法 | 定義自 | ||
---|---|---|---|
Constructor. | SpriteAsset | ||
將 DisplayObject 子實體加入至此 DisplayObjectContainer 實體。 | DisplayObjectContainer | ||
將 DisplayObject 子實體加入至此 DisplayObjectContainer 實體。 | DisplayObjectContainer | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。 | EventDispatcher | ||
指出安全性限制是否會造成傳回的清單 (可用指定的 point 點呼叫 DisplayObjectContainer.getObjectsUnderPoint() 方法來取得) 省略任何顯示物件。 | DisplayObjectContainer | ||
判斷指定的顯示物件是否為 DisplayObjectContainer 實體的子系,或為實體本身。 | DisplayObjectContainer | ||
會將事件傳送到事件流程。 | EventDispatcher | ||
傳回可定義顯示物件區域 (相對於 targetCoordinateSpace 物件的座標系統) 的矩形。 | DisplayObject | ||
傳回存在於指定索引位置的子顯示物件實體。 | DisplayObjectContainer | ||
傳回具有指定名稱的子顯示物件。 | DisplayObjectContainer | ||
傳回 child DisplayObject 實體的索引位置。 | DisplayObjectContainer | ||
傳回位於指定點底下,且屬於此 DisplayObjectContainer 實體之子系 (或孫系,以下類推) 的物件陣列。 | DisplayObjectContainer | ||
根據 targetCoordinateSpace 參數所定義的座標系統,並排除形狀上的任何筆畫,傳回可定義顯示物件邊界的矩形。 | DisplayObject | ||
將 point 物件從「舞台」(全域) 座標轉換成顯示物件的 (區域) 座標。 | DisplayObject | ||
將二維點從「舞台」(全域) 座標轉換為三維顯示物件的 (區域) 座標。 | DisplayObject | ||
會檢查 EventDispatcher 物件是否有對特定的事件類型註冊偵聽程式。 | EventDispatcher | ||
指出物件是否有已定義的指定屬性。 | Object | ||
評估顯示物件的範圍框,看它是否與 obj 顯示物件的範圍框重疊或相交。 | DisplayObject | ||
評估顯示物件,看它是否與 x 和 y 參數所指定的點重疊或相交。 | DisplayObject | ||
An element must call this method when its layoutDirection changes or
when its parent's layoutDirection changes. | SpriteAsset | ||
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。 | Object | ||
將三維顯示物件的 (區域) 座標的三維點轉換為「舞台」(全域) 座標中的二維點。 | DisplayObject | ||
將 point 物件從顯示物件的 (區域) 座標轉換成「舞台」(全域) 座標。 | DisplayObject | ||
Moves this object to the specified x and y coordinates. | SpriteAsset | ||
指出指定的屬性是否存在,以及是否可列舉。 | Object | ||
將指定的 child DisplayObject 實體從 DisplayObjectContainer 實體的子清單中移除。 | DisplayObjectContainer | ||
從 DisplayObjectContainer 子清單中的指定索引位置移除子 DisplayObject。 | DisplayObjectContainer | ||
將所有 child DisplayObject 實體從 DisplayObjectContainer 實體的子清單中移除。 | DisplayObjectContainer | ||
會從 EventDispatcher 物件移除偵聽程式。 | EventDispatcher | ||
升起顯示虛擬鍵盤。 | InteractiveObject | ||
Sets the actual size of this object. | SpriteAsset | ||
變更顯示物件容器中現有子系的位置。 | DisplayObjectContainer | ||
為迴圈作業設定動態屬性的可用性。 | Object | ||
讓使用者拖曳指定的 sprite。 | Sprite | ||
讓使用者將指定的 Sprite 拖曳至觸控裝置上。 | Sprite | ||
遞迴停止執行所有 MovieClips 的時間軸根源於此物件。 | DisplayObjectContainer | ||
結束 startDrag() 方法。 | Sprite | ||
結束觸控裝置使用的 startTouchDrag() 方法。 | Sprite | ||
替換兩個指定子物件的 z 順序 (深度階層,由前至後順序)。 | DisplayObjectContainer | ||
在子清單的兩個指定索引位置,替換子物件的 z 順序 (深度階層,由前至後順序)。 | DisplayObjectContainer | ||
傳回代表此物件的字串,根據地區特定慣例進行格式化。 | Object | ||
[覆寫]
Returns a string indicating the location of this object
within the hierarchy of DisplayObjects in the Application. | FlexSprite | ||
會傳回指定之物件的基本值。 | Object | ||
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。 | EventDispatcher |
borderMetrics | 屬性 |
borderMetrics:EdgeMetrics
[唯讀] 語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
Returns an EdgeMetrics object for the border that has four properties:
left
, top
, right
,
and bottom
.
The value of each property is equal to the thickness of one side
of the border, in pixels.
實作
public function get borderMetrics():EdgeMetrics
layoutDirection | 屬性 |
layoutDirection:String
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4.1 |
執行階段版本: | Flash Player 10, AIR 1.5 |
Specifies the desired layout direction for an element: one of LayoutDirection.LTR (left to right), LayoutDirection.RTL (right to left), or null (inherit). This property is typically backed by an inheriting style. If null, the layoutDirection style will be set to undefined. Classes like GraphicElement, which implement ILayoutDirectionElement but do not support styles, must additionally support a null value for this property which means the layoutDirection must be inherited from its parent.
實作
public function get layoutDirection():String
public function set layoutDirection(value:String):void
measuredHeight | 屬性 |
measuredHeight:Number
[唯讀] 語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
The measured height of this object.
This is typically hard-coded for graphical skins
because this number is simply the number of pixels in the graphic.
For code skins, it can also be hard-coded
if you expect to be drawn at a certain size.
If your size can change based on properties, you may want
to also be an ILayoutManagerClient so a measure()
method will be called at an appropriate time,
giving you an opportunity to compute a measuredHeight
.
實作
public function get measuredHeight():Number
measuredWidth | 屬性 |
measuredWidth:Number
[唯讀] 語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
The measured width of this object.
This is typically hard-coded for graphical skins
because this number is simply the number of pixels in the graphic.
For code skins, it can also be hard-coded
if you expect to be drawn at a certain size.
If your size can change based on properties, you may want
to also be an ILayoutManagerClient so a measure()
method will be called at an appropriate time,
giving you an opportunity to compute a measuredHeight
.
實作
public function get measuredWidth():Number
SpriteAsset | () | 建構函式 |
public function SpriteAsset()
語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
Constructor.
invalidateLayoutDirection | () | 方法 |
public function invalidateLayoutDirection():void
語言版本: | ActionScript 3.0 |
產品版本: | Flex 4.1 |
執行階段版本: | Flash Player 10, AIR 1.5 |
An element must call this method when its layoutDirection changes or when its parent's layoutDirection changes. If they differ, this method is responsible for mirroring the element’s contents and for updating the element’s post-layout transform so that descendants inherit a mirrored coordinate system. IVisualElements typically implement mirroring by using postLayoutTransformOffsets to scale the X axis by -1 and to translate the x coordinate of the origin by the element's width. The net effect of this "mirror" transform is to reverse the direction in which the X axis increases without changing the element's location relative to its parent's origin.
move | () | 方法 |
setActualSize | () | 方法 |
public function setActualSize(newWidth:Number, newHeight:Number):void
語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
Sets the actual size of this object.
This method is mainly for use in implementing the
updateDisplayList()
method, which is where
you compute this object's actual size based on
its explicit size, parent-relative (percent) size,
and measured size.
You then apply this actual size to the object
by calling setActualSize()
.
In other situations, you should be setting properties
such as width
, height
,
percentWidth
, or percentHeight
rather than calling this method.
參數
newWidth:Number — The new width for this object.
| |
newHeight:Number — The new height for this object.
|
Tue Jun 12 2018, 03:47 PM Z