class AssetLoader
package feathers.controls
extends FeathersControl › MeasureSprite › ValidatingSprite
Loads and displays an asset using either OpenFL's asset management system or from a URL.
Supports assets of the following types:
Events:
openfl.events.Event.COMPLETE | Dispatched when |
---|---|
openfl.events.ProgressEvent.PROGRESS | Dispatched periodically as
|
openfl.events.IOErrorEvent.IO_ERROR | Dispatched if an IO error occurs
while loading |
openfl.events.SecurityErrorEvent.SECURITY_ERROR | Dispatched if a
security error occurs while loading |
1.0.0
.See also:
Constructor
new(?source:String, ?completeListener:Event ‑> Void)
Creates a new AssetLoader
object.
1.0.0
.Variables
read onlyoriginalSourceHeight:Null<Float>
The original height of the source asset, measured in pixels. May return
null
, if the source
is null
, or if the source
has not yet
completed loading.
1.0.0
.See also:
read onlyoriginalSourceWidth:Null<Float>
The original width of the source
asset, measured in pixels. May return
null
, if the source
is null
, or if the source
has not yet
completed loading.
1.0.0
.See also:
scaleMode:StageScaleMode
Determines how the asset will be scaled within the width and height of
the AssetLoader
instance. Uses the same constants from
StageScaleMode
that are used to scale the OpenFL stage.
The following example maintains the aspect ratio of the asset, but displays no border, and may crop it to fit:
loader.scaleMode = StageScaleMode.NO_BORDER
1.0.0
.See also:
source:String
Sets the loader's source, which may be either the name of an asset or a URL to load the asset from the web instead.
The following example sets the source to an asset name:
loader.source = "my-asset-name";
The following example sets the source to a URL:
loader.source = "https://example.com/my-asset.png";
1.0.0
.sourceScale:Float
Scales the source content for measurement. For example, if assets are designed for a scale factor of 2.0, they can be displayed at 0.5 scale to appear crisp (because displays bitmaps at the original dimensions, as if the scale factor were 1.0).
loader.sourceScale = 0.5;
1.3.0
.