套件 | mx.core |
類別 | public class BitmapAsset |
繼承 | BitmapAsset FlexBitmap Bitmap DisplayObject EventDispatcher Object |
實作 | IFlexAsset, IFlexDisplayObject, ILayoutDirectionElement |
語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
The bitmap image that you're embedding can be in a JPEG, GIF, or PNG file. You can also embed a bitmap symbol that is in a SWF file produced by Flash. In each of these cases, the MXML compiler autogenerates a class that extends BitmapAsset to represent the embedded bitmap image.
You don't generally have to use the BitmapAsset class directly when you write a Flex application. For example, you can embed a GIF file and display the image in an Image control by writing the gollowing:
<mx:Image id="logo" source="@Embed(source='Logo.gif')"/>
or use it as the application's background image in CSS syntax by writing
<fx:Style> @namespace mx "library://ns.adobe.com/flex/mx" mx|Application { backgroundImage: Embed(source="Logo.gif") } <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 bitmap image in ActionScript, you declare a variable
of type Class, and put [Embed]
metadata on it.
For example, you embed a GIF file like this:
[Bindable] [Embed(source="Logo.gif")] private var logoClass:Class;
The MXML compiler sees the .gif extension, transcodes the GIF data
into the bitmap format that the player uses, autogenerates
a subclass of the BitmapAsset class, and sets your variable
to be a reference to this autogenerated class.
You can then use this class reference to create instances of the
BitmapAsset using the new
operator, and you can use
APIs of the BitmapAsset class on them:
var logo:BitmapAsset = BitmapAsset(new logoClass()); logo.bitmapData.noise(4);
However, you rarely need to create BitmapAsset 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 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}"/>
屬性 | 定義自 | ||
---|---|---|---|
accessibilityProperties : AccessibilityProperties
此顯示物件的目前輔助功能選項。 | DisplayObject | ||
alpha : Number
指出所指定物件的 Alpha 透明度值。 | DisplayObject | ||
bitmapData : BitmapData
參照中的 BitmapData 物件。 | Bitmap | ||
blendMode : String
來自 BlendMode 類別的值,會指定要使用何種混合模式。 | DisplayObject | ||
blendShader : Shader [唯寫]
設定用來混合前景和背景的著色器。 | DisplayObject | ||
cacheAsBitmap : Boolean
如果設定為 true,Flash 執行階段會快取顯示物件的內部點陣圖表示法。 | DisplayObject | ||
cacheAsBitmapMatrix : Matrix
如果為非 null,當 cacheAsBitmap 設定為 true 時,這個 Matrix 物件會定義顯示物件的顯示方法。 | DisplayObject | ||
constructor : Object
類別物件的參照或是特定物件實體的建構函數。 | Object | ||
filters : Array
索引的陣列,其中包含目前和顯示物件相關的每個濾鏡物件。 | DisplayObject | ||
height : Number
會指出顯示物件的高度,以像素為單位。 | DisplayObject | ||
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). | BitmapAsset | ||
loaderInfo : LoaderInfo [唯讀]
會傳回 LoaderInfo 物件,其中包含關於載入此顯示物件所屬之檔案的資訊。 | DisplayObject | ||
mask : DisplayObject
呼叫之顯示物件會以指定的 mask 物件遮蓋。 | DisplayObject | ||
measuredHeight : Number [唯讀]
The measured height of this object. | BitmapAsset | ||
measuredWidth : Number [唯讀]
The measured width of this object. | BitmapAsset | ||
metaData : Object
如果中繼資料是透過 PlaceObject4 標籤與 SWF 檔案中的這個 DisplayObject 實體一同儲存,則會取得 DisplayObject 實體的中繼資料物件。 | DisplayObject | ||
mouseX : Number [唯讀]
指出滑鼠或使用者輸入裝置位置的 x 座標,以像素為單位。 | DisplayObject | ||
mouseY : Number [唯讀]
指出滑鼠或使用者輸入裝置位置的 y 座標,以像素為單位。 | DisplayObject | ||
name : String
指出 DisplayObject 的實體名稱。 | DisplayObject | ||
opaqueBackground : Object
會指定顯示物件是否不透明,並具有特定背景顏色。 | DisplayObject | ||
parent : DisplayObjectContainer [唯讀]
指出包含此顯示物件的 DisplayObjectContainer 物件。 | DisplayObject | ||
pixelSnapping : String
控制 Bitmap 物件是否貼齊最近的像素。 | Bitmap | ||
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 | ||
smoothing : Boolean
控制點陣圖是否在縮放時平滑化處理。 | Bitmap | ||
stage : Stage [唯讀]
顯示物件的「舞台」。 | DisplayObject | ||
transform : flash.geom:Transform
這是一個物件,具有和顯示物件的矩陣、顏色轉換和像素邊界有關的屬性。 | DisplayObject | ||
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. | BitmapAsset | ||
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
會在 EventDispatcher 物件註冊事件偵聽程式,以便讓偵聽程式收到事件的通知。 | EventDispatcher | ||
會將事件傳送到事件流程。 | EventDispatcher | ||
傳回可定義顯示物件區域 (相對於 targetCoordinateSpace 物件的座標系統) 的矩形。 | DisplayObject | ||
根據 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. | BitmapAsset | ||
指出 Object 類別的實體是否位於指定為參數的物件原型鏈中。 | Object | ||
將三維顯示物件的 (區域) 座標的三維點轉換為「舞台」(全域) 座標中的二維點。 | DisplayObject | ||
將 point 物件從顯示物件的 (區域) 座標轉換成「舞台」(全域) 座標。 | DisplayObject | ||
Moves this object to the specified x and y coordinates. | BitmapAsset | ||
指出指定的屬性是否存在,以及是否可列舉。 | Object | ||
會從 EventDispatcher 物件移除偵聽程式。 | EventDispatcher | ||
Sets the actual size of this object. | BitmapAsset | ||
為迴圈作業設定動態屬性的可用性。 | Object | ||
傳回代表此物件的字串,根據地區特定慣例進行格式化。 | Object | ||
[覆寫]
Returns a string indicating the location of this object
within the hierarchy of DisplayObjects in the Application. | FlexBitmap | ||
會傳回指定之物件的基本值。 | Object | ||
檢查此 EventDispatcher 物件是否已註冊事件偵聽程式,或者此物件的任何祖系已為特定事件類型註冊事件偵聽程式。 | EventDispatcher |
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
BitmapAsset | () | 建構函式 |
public function BitmapAsset(bitmapData:BitmapData = null, pixelSnapping:String = "auto", smoothing:Boolean = false)
語言版本: | ActionScript 3.0 |
產品版本: | Flex 3 |
執行階段版本: | Flash Player 9, AIR 1.1 |
Constructor.
參數bitmapData:BitmapData (default = null ) — The data for the bitmap image.
| |
pixelSnapping:String (default = "auto ") — Whether or not the bitmap is snapped
to the nearest pixel.
| |
smoothing:Boolean (default = false ) — Whether or not the bitmap is smoothed when scaled.
|
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