-
Notifications
You must be signed in to change notification settings - Fork 385
/
ImageLoader.as
2097 lines (1944 loc) · 55.7 KB
/
ImageLoader.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Feathers
Copyright 2012-2015 Bowler Hat LLC. All Rights Reserved.
This program is free software. You can redistribute and/or modify it in
accordance with the terms of the accompanying license agreement.
*/
package feathers.controls
{
import feathers.core.FeathersControl;
import feathers.events.FeathersEventType;
import feathers.skins.IStyleProvider;
import feathers.utils.display.stageToStarling;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.display3D.Context3DTextureFormat;
import flash.errors.IllegalOperationError;
import flash.events.ErrorEvent;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.ProgressEvent;
import flash.events.SecurityErrorEvent;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.system.ImageDecodingPolicy;
import flash.system.LoaderContext;
import flash.utils.ByteArray;
import flash.utils.setTimeout;
import starling.core.RenderSupport;
import starling.core.Starling;
import starling.display.Image;
import starling.events.EnterFrameEvent;
import starling.events.Event;
import starling.textures.Texture;
import starling.textures.TextureSmoothing;
import starling.utils.RectangleUtil;
import starling.utils.ScaleMode;
import starling.utils.SystemUtil;
/**
* Dispatched when the source finishes loading, if the source is a URL. This
* event is not dispatched when the source is a texture.
*
* <p>The properties of the event object have the following values:</p>
* <table class="innertable">
* <tr><th>Property</th><th>Value</th></tr>
* <tr><td><code>bubbles</code></td><td>false</td></tr>
* <tr><td><code>currentTarget</code></td><td>The Object that defines the
* event listener that handles the event. For example, if you use
* <code>myButton.addEventListener()</code> to register an event listener,
* myButton is the value of the <code>currentTarget</code>.</td></tr>
* <tr><td><code>data</code></td><td>null</td></tr>
* <tr><td><code>target</code></td><td>The Object that dispatched the event;
* it is not always the Object listening for the event. Use the
* <code>currentTarget</code> property to always access the Object
* listening for the event.</td></tr>
* </table>
*
* @eventType starling.events.Event.COMPLETE
*/
[Event(name="complete",type="starling.events.Event")]
/**
* Dispatched periodically as the source loads, if the source is a URL. This
* event is not dispatched when the source is a texture.
*
* <p>The properties of the event object have the following values:</p>
* <table class="innertable">
* <tr><th>Property</th><th>Value</th></tr>
* <tr><td><code>bubbles</code></td><td>false</td></tr>
* <tr><td><code>currentTarget</code></td><td>The Object that defines the
* event listener that handles the event. For example, if you use
* <code>myButton.addEventListener()</code> to register an event listener,
* myButton is the value of the <code>currentTarget</code>.</td></tr>
* <tr><td><code>data</code></td><td>A value between 0.0 and 1.0 to indicate
* how much image data has loaded.</td></tr>
* <tr><td><code>target</code></td><td>The Object that dispatched the event;
* it is not always the Object listening for the event. Use the
* <code>currentTarget</code> property to always access the Object
* listening for the event.</td></tr>
* </table>
*
* @eventType feathers.events.FeathersEventType.PROGRESS
*/
[Event(name="progress",type="starling.events.Event")]
/**
* DEPRECATED: Replaced by <code>Event.IO_ERROR</code> and
* <code>Event.SECURITY_ERROR</code>.
*
* <p><strong>DEPRECATION WARNING:</strong> This event is deprecated
* starting with Feathers 2.2. It will be removed in a future version of
* Feathers according to the standard
* <a target="_top" href="../../../help/deprecation-policy.html">Feathers deprecation policy</a>.</p>
*
* @eventType feathers.events.FeathersEventType.ERROR
*
* @see #event:ioError
* @see #event:securityError
*/
[Event(name="error",type="starling.events.Event")]
/**
* Dispatched if an IO error occurs while loading the source content.
*
* <p>The properties of the event object have the following values:</p>
* <table class="innertable">
* <tr><th>Property</th><th>Value</th></tr>
* <tr><td><code>bubbles</code></td><td>false</td></tr>
* <tr><td><code>currentTarget</code></td><td>The Object that defines the
* event listener that handles the event. For example, if you use
* <code>myButton.addEventListener()</code> to register an event listener,
* myButton is the value of the <code>currentTarget</code>.</td></tr>
* <tr><td><code>data</code></td><td>The <code>flash.events.IOErrorEvent</code>
* dispatched by the loader.</td></tr>
* <tr><td><code>target</code></td><td>The Object that dispatched the event;
* it is not always the Object listening for the event. Use the
* <code>currentTarget</code> property to always access the Object
* listening for the event.</td></tr>
* </table>
*
* @eventType starling.events.Event.IO_ERROR
*/
[Event(name="ioError",type="starling.events.Event")]
/**
* Dispatched if a security error occurs while loading the source content.
*
* <p>The properties of the event object have the following values:</p>
* <table class="innertable">
* <tr><th>Property</th><th>Value</th></tr>
* <tr><td><code>bubbles</code></td><td>false</td></tr>
* <tr><td><code>currentTarget</code></td><td>The Object that defines the
* event listener that handles the event. For example, if you use
* <code>myButton.addEventListener()</code> to register an event listener,
* myButton is the value of the <code>currentTarget</code>.</td></tr>
* <tr><td><code>data</code></td><td>The <code>flash.events.SecurityErrorEvent</code>
* dispatched by the loader.</td></tr>
* <tr><td><code>target</code></td><td>The Object that dispatched the event;
* it is not always the Object listening for the event. Use the
* <code>currentTarget</code> property to always access the Object
* listening for the event.</td></tr>
* </table>
*
* @eventType starling.events.Event.SECURITY_ERROR
*/
[Event(name="securityError",type="starling.events.Event")]
/**
* Displays an image, either from an existing <code>Texture</code> object or
* from an image file loaded with its URL. Supported image files include ATF
* format and any bitmap formats that may be loaded by
* <code>flash.display.Loader</code>, including JPG, GIF, and PNG.
*
* <p>The following example passes a URL to an image loader and listens for
* its complete event:</p>
*
* <listing version="3.0">
* var loader:ImageLoader = new ImageLoader();
* loader.source = "http://example.com/example.png";
* loader.addEventListener( Event.COMPLETE, loader_completeHandler );
* this.addChild( loader );</listing>
*
* <p>The following example passes an existing texture to an image loader:</p>
*
* <listing version="3.0">
* var loader:ImageLoader = new ImageLoader();
* loader.source = Texture.fromBitmap( bitmap );
* this.addChild( loader );</listing>
*/
public class ImageLoader extends FeathersControl
{
/**
* @private
*/
private static const HELPER_MATRIX:Matrix = new Matrix();
/**
* @private
*/
private static const HELPER_RECTANGLE:Rectangle = new Rectangle();
/**
* @private
*/
private static const HELPER_RECTANGLE2:Rectangle = new Rectangle();
/**
* @private
*/
private static const CONTEXT_LOST_WARNING:String = "ImageLoader: Context lost while processing loaded image, retrying...";
/**
* @private
*/
protected static const LOADER_CONTEXT:LoaderContext = new LoaderContext(true);
LOADER_CONTEXT.imageDecodingPolicy = ImageDecodingPolicy.ON_LOAD;
/**
* @private
*/
protected static const ATF_FILE_EXTENSION:String = "atf";
/**
* @private
*/
protected static var textureQueueHead:ImageLoader;
/**
* @private
*/
protected static var textureQueueTail:ImageLoader;
/**
* The content will be aligned horizontally to the left edge of the
* <code>ImageLoader</code>.
*
* @see #horizontalAlign
*/
public static const HORIZONTAL_ALIGN_LEFT:String = "left";
/**
* The content will be aligned horizontally to the center of the
* <code>ImageLoader</code>.
*
* @see #horizontalAlign
*/
public static const HORIZONTAL_ALIGN_CENTER:String = "center";
/**
* The content will be aligned horizontally to the right edge of the
* <code>ImageLoader</code>.
*
* @see #horizontalAlign
*/
public static const HORIZONTAL_ALIGN_RIGHT:String = "right";
/**
* The content will be aligned vertically to the top edge of the
* <code>ImageLoader</code>.
*
* @see #verticalAlign
*/
public static const VERTICAL_ALIGN_TOP:String = "top";
/**
* The content will be aligned vertically to the middle of the
* <code>ImageLoader</code>.
*
* @see #verticalAlign
*/
public static const VERTICAL_ALIGN_MIDDLE:String = "middle";
/**
* The content will be aligned vertically to the bottom edge of the
* <code>ImageLoader</code>.
*
* @see #verticalAlign
*/
public static const VERTICAL_ALIGN_BOTTOM:String = "bottom";
/**
* The default <code>IStyleProvider</code> for all <code>ImageLoader</code>
* components.
*
* @default null
* @see feathers.core.FeathersControl#styleProvider
*/
public static var globalStyleProvider:IStyleProvider;
/**
* Constructor.
*/
public function ImageLoader()
{
this.isQuickHitAreaEnabled = true;
}
/**
* The internal <code>starling.display.Image</code> child.
*/
protected var image:Image;
/**
* The internal <code>flash.display.Loader</code> used to load textures
* from URLs.
*/
protected var loader:Loader;
/**
* The internal <code>flash.net.URLLoader</code> used to load raw data
* from URLs.
*/
protected var urlLoader:URLLoader;
/**
* @private
*/
protected var _lastURL:String;
/**
* @private
*/
protected var _currentTextureWidth:Number = NaN;
/**
* @private
*/
protected var _currentTextureHeight:Number = NaN;
/**
* @private
*/
protected var _currentTexture:Texture;
/**
* @private
*/
protected var _texture:Texture;
/**
* @private
*/
protected var _textureBitmapData:BitmapData;
/**
* @private
*/
protected var _textureRawData:ByteArray;
/**
* @private
*/
protected var _isTextureOwner:Boolean = false;
/**
* @private
*/
override protected function get defaultStyleProvider():IStyleProvider
{
return ImageLoader.globalStyleProvider;
}
/**
* @private
*/
protected var _source:Object;
/**
* The <code>Texture</code> to display, or a URL pointing to an image
* file. Supported image files include ATF format and any bitmap formats
* that may be loaded by <code>flash.display.Loader</code>, including
* JPG, GIF, and PNG.
*
* <p>In the following example, the image loader's source is set to a
* texture:</p>
*
* <listing version="3.0">
* loader.source = Texture.fromBitmap( bitmap );</listing>
*
* <p>In the following example, the image loader's source is set to the
* URL of a PNG image:</p>
*
* <listing version="3.0">
* loader.source = "http://example.com/example.png";</listing>
*
* @default null
*
* @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html
* @see http://wiki.starling-framework.org/manual/atf_textures
*/
public function get source():Object
{
return this._source;
}
/**
* @private
*/
public function set source(value:Object):void
{
if(this._source == value)
{
return;
}
if(this._isInTextureQueue)
{
this.removeFromTextureQueue();
}
this._source = value;
this.cleanupTexture();
if(this.image)
{
this.image.visible = false;
}
this._lastURL = null;
if(this._source is Texture)
{
this._isLoaded = true;
}
else
{
this._isLoaded = false;
}
this.invalidate(INVALIDATION_FLAG_DATA);
}
/**
* @private
*/
protected var _loadingTexture:Texture;
/**
* A texture to display while a URL source is loading.
*
* <p>In the following example, the image loader's loading texture is
* customized:</p>
*
* <listing version="3.0">
* loader.source = "http://example.com/example.png";
* loader.loadingTexture = texture;</listing>
*
* @default null
*
* @see #errorTexture
*/
public function get loadingTexture():Texture
{
return this._loadingTexture;
}
/**
* @private
*/
public function set loadingTexture(value:Texture):void
{
if(this._loadingTexture == value)
{
return;
}
this._loadingTexture = value;
this.invalidate(INVALIDATION_FLAG_STYLES);
}
/**
* @private
*/
protected var _errorTexture:Texture;
/**
* A texture to display when a URL source cannot be loaded for any
* reason.
*
* <p>In the following example, the image loader's error texture is
* customized:</p>
*
* <listing version="3.0">
* loader.source = "http://example.com/example.png";
* loader.errorTexture = texture;</listing>
*
* @default null
*
* @see #loadingTexture
*/
public function get errorTexture():Texture
{
return this._errorTexture;
}
/**
* @private
*/
public function set errorTexture(value:Texture):void
{
if(this._errorTexture == value)
{
return;
}
this._errorTexture = value;
this.invalidate(INVALIDATION_FLAG_STYLES);
}
/**
* @private
*/
protected var _isLoaded:Boolean = false;
/**
* Indicates if the source has completed loading, if the source is a
* URL. Always returns <code>true</code> when the source is a texture.
*
* <p>In the following example, we check if the image loader's source
* has finished loading:</p>
*
* <listing version="3.0">
* if( loader.isLoaded )
* {
* //do something
* }</listing>
*/
public function get isLoaded():Boolean
{
return this._isLoaded;
}
/**
* @private
*/
private var _textureScale:Number = 1;
/**
* Scales the texture dimensions during measurement. Useful for UI that
* should scale based on screen density or resolution.
*
* <p>In the following example, the image loader's texture scale is
* customized:</p>
*
* <listing version="3.0">
* loader.textureScale = 0.5;</listing>
*
* @default 1
*/
public function get textureScale():Number
{
return this._textureScale;
}
/**
* @private
*/
public function set textureScale(value:Number):void
{
if(this._textureScale == value)
{
return;
}
this._textureScale = value;
this.invalidate(INVALIDATION_FLAG_SIZE);
}
/**
* @private
*/
private var _smoothing:String = TextureSmoothing.BILINEAR;
/**
* The smoothing value to use on the internal <code>Image</code>.
*
* <p>In the following example, the image loader's smoothing is set to a
* custom value:</p>
*
* <listing version="3.0">
* loader.smoothing = TextureSmoothing.NONE;</listing>
*
* @default starling.textures.TextureSmoothing.BILINEAR
*
* @see http://doc.starling-framework.org/core/starling/textures/TextureSmoothing.html starling.textures.TextureSmoothing
* @see http://doc.starling-framework.org/core/starling/display/Image.html#smoothing starling.display.Image.smoothing
*/
public function get smoothing():String
{
return this._smoothing;
}
/**
* @private
*/
public function set smoothing(value:String):void
{
if(this._smoothing == value)
{
return;
}
this._smoothing = value;
this.invalidate(INVALIDATION_FLAG_STYLES);
}
/**
* @private
*/
private var _color:uint = 0xffffff;
/**
* The tint value to use on the internal <code>Image</code>.
*
* <p>In the following example, the image loader's texture color is
* customized:</p>
*
* <listing version="3.0">
* loader.color = 0xff00ff;</listing>
*
* @default 0xffffff
*
* @see http://doc.starling-framework.org/core/starling/display/Image.html#color starling.display.Image.color
*/
public function get color():uint
{
return this._color;
}
/**
* @private
*/
public function set color(value:uint):void
{
if(this._color == value)
{
return;
}
this._color = value;
this.invalidate(INVALIDATION_FLAG_STYLES);
}
/**
* @private
*/
private var _textureFormat:String = Context3DTextureFormat.BGRA;
/**
* The texture format to use when creating a texture loaded from a URL.
*
* <p>In the following example, the image loader's texture format is set
* to a custom value:</p>
*
* <listing version="3.0">
* loader.textureFormat = Context3DTextureFormat.BGRA_PACKED;</listing>
*
* @default flash.display3d.Context3DTextureFormat.BGRA
*
* @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display3D/Context3DTextureFormat.html flash.display3d.Context3DTextureFormat
*/
public function get textureFormat():String
{
return this._textureFormat;
}
/**
* @private
*/
public function set textureFormat(value:String):void
{
if(this._textureFormat == value)
{
return;
}
this._textureFormat = value;
this._lastURL = null;
this.invalidate(INVALIDATION_FLAG_DATA);
}
/**
* @private
*/
private var _snapToPixels:Boolean = false;
/**
* Determines if the image should be snapped to the nearest global whole
* pixel when rendered. Turning this on helps to avoid blurring.
*
* <p>In the following example, the image loader's position is snapped
* to pixels:</p>
*
* <listing version="3.0">
* loader.snapToPixels = true;</listing>
*
* @default false
*/
public function get snapToPixels():Boolean
{
return this._snapToPixels;
}
/**
* @private
*/
public function set snapToPixels(value:Boolean):void
{
if(this._snapToPixels == value)
{
return;
}
this._snapToPixels = value;
}
/**
* @private
*/
private var _scaleContent:Boolean = true;
/**
* Determines if the content will be scaled if the dimensions of the
* <code>ImageLoader</code> are changed.
*
* <p>In the following example, the image loader's content is not
* scaled:</p>
*
* <listing version="3.0">
* loader.scaleContent = false;</listing>
*
* @default true
*
* @see #horizontalAlign
* @see #verticalAlign
* @see #maintainAspectRatio
*/
public function get scaleContent():Boolean
{
return this._scaleContent;
}
/**
* @private
*/
public function set scaleContent(value:Boolean):void
{
if(this._scaleContent == value)
{
return;
}
this._scaleContent = value;
this.invalidate(INVALIDATION_FLAG_LAYOUT);
}
/**
* @private
*/
private var _maintainAspectRatio:Boolean = true;
/**
* Determines if the aspect ratio of the texture is maintained when the
* dimensions of the <code>ImageLoader</code> are changed manually and
* the new dimensions have a different aspect ratio than the texture.
*
* <p>If the <code>scaleContent</code> property is set to
* <code>false</code>, the <code>maintainAspectRatio</code> property is
* ignored.</p>
*
* <p>In the following example, the image loader's aspect ratio is not
* maintained:</p>
*
* <listing version="3.0">
* loader.maintainAspectRatio = false;</listing>
*
* @default true
*
* @see #scaleContent
*/
public function get maintainAspectRatio():Boolean
{
return this._maintainAspectRatio;
}
/**
* @private
*/
public function set maintainAspectRatio(value:Boolean):void
{
if(this._maintainAspectRatio == value)
{
return;
}
this._maintainAspectRatio = value;
this.invalidate(INVALIDATION_FLAG_LAYOUT);
}
/**
* @private
*/
private var _scaleMode:String = ScaleMode.SHOW_ALL;
[Inspectable(type="String",enumeration="showAll,noBorder,none")]
/**
* Determines how the texture is scaled if <code>scaleContent</code> and
* <code>maintainAspectRatio</code> are both set to <code>true</code>.
* See the <code>starling.utils.ScaleMode</code> class for details about
* each scaling mode.
*
* <p>If the <code>scaleContent</code> property is set to
* <code>false</code>, or the <code>maintainAspectRatio</code> property
* is set to false, the <code>scaleMode</code> property is ignored.</p>
*
* <p>In the following example, the image loader's aspect ratio is not
* maintained:</p>
*
* <listing version="3.0">
* loader.scaleMode = ScaleMode.NO_BORDER;</listing>
*
* @default starling.utils.ScaleMode.SHOW_ALL
*
* @see #scaleContent
* @see #maintainAspectRatio
* @see http://doc.starling-framework.org/core/starling/utils/ScaleMode.html starling.utils.ScaleMode
*/
public function get scaleMode():String
{
return this._scaleMode;
}
/**
* @private
*/
public function set scaleMode(value:String):void
{
if(this._scaleMode == value)
{
return;
}
this._scaleMode = value;
this.invalidate(INVALIDATION_FLAG_LAYOUT);
}
/**
* @private
*/
protected var _horizontalAlign:String = HORIZONTAL_ALIGN_LEFT;
[Inspectable(type="String",enumeration="left,center,right")]
/**
* The location where the content is aligned horizontally (on
* the x-axis) when its width is larger or smaller than the width of
* the <code>ImageLoader</code>.
*
* <p>If the <code>scaleContent</code> property is set to
* <code>true</code>, the <code>horizontalAlign</code> property is
* ignored.</p>
*
* <p>The following example aligns the content to the right:</p>
*
* <listing version="3.0">
* loader.horizontalAlign = ImageLoader.HORIZONTAL_ALIGN_RIGHT;</listing>
*
* @default ImageLoader.HORIZONTAL_ALIGN_LEFT
*
* @see #scaleContent
* @see #HORIZONTAL_ALIGN_LEFT
* @see #HORIZONTAL_ALIGN_CENTER
* @see #HORIZONTAL_ALIGN_RIGHT
*/
public function get horizontalAlign():String
{
return this._horizontalAlign;
}
/**
* @private
*/
public function set horizontalAlign(value:String):void
{
if(this._horizontalAlign == value)
{
return;
}
this._horizontalAlign = value;
this.invalidate(INVALIDATION_FLAG_STYLES);
}
/**
* @private
*/
protected var _verticalAlign:String = VERTICAL_ALIGN_TOP;
[Inspectable(type="String",enumeration="top,middle,bottom")]
/**
* The location where the content is aligned vertically (on
* the y-axis) when its height is larger or smaller than the height of
* the <code>ImageLoader</code>.
*
* <p>If the <code>scaleContent</code> property is set to
* <code>true</code>, the <code>verticalAlign</code> property is
* ignored.</p>
*
* <p>The following example aligns the content to the bottom:</p>
*
* <listing version="3.0">
* loader.verticalAlign = ImageLoader.VERTICAL_ALIGN_BOTTOM;</listing>
*
* @default ImageLoader.VERTICAL_ALIGN_TOP
*
* @see #scaleContent
* @see #VERTICAL_ALIGN_TOP
* @see #VERTICAL_ALIGN_MIDDLE
* @see #VERTICAL_ALIGN_BOTTOM
*/
public function get verticalAlign():String
{
return _verticalAlign;
}
/**
* @private
*/
public function set verticalAlign(value:String):void
{
if(this._verticalAlign == value)
{
return;
}
this._verticalAlign = value;
this.invalidate(INVALIDATION_FLAG_STYLES);
}
/**
* The original width of the source content, in pixels. This value will
* be <code>0</code> until the source content finishes loading. If the
* source is a texture, this value will be <code>0</code> until the
* <code>ImageLoader</code> validates.
*/
public function get originalSourceWidth():Number
{
if(this._currentTextureWidth === this._currentTextureWidth) //!isNaN
{
return this._currentTextureWidth;
}
return 0;
}
/**
* The original height of the source content, in pixels. This value will
* be <code>0</code> until the source content finishes loading. If the
* source is a texture, this value will be <code>0</code> until the
* <code>ImageLoader</code> validates.
*/
public function get originalSourceHeight():Number
{
if(this._currentTextureHeight === this._currentTextureHeight) //!isNaN
{
return this._currentTextureHeight;
}
return 0;
}
/**
* @private
*/
protected var _pendingBitmapDataTexture:BitmapData;
/**
* @private
*/
protected var _pendingRawTextureData:ByteArray;
/**
* @private
*/
protected var _delayTextureCreation:Boolean = false;
/**
* Determines if a loaded bitmap may be converted to a texture
* immediately after loading. If <code>true</code>, the loaded bitmap
* will be saved until this property is set to <code>false</code>, and
* only then it will be used to create the texture.
*
* <p>This property is intended to be used while a parent container,
* such as a <code>List</code>, is scrolling in order to keep scrolling
* as smooth as possible. Creating textures is expensive and performance
* can be affected by it. Set this property to <code>true</code> when
* the <code>List</code> dispatches <code>FeathersEventType.SCROLL_START</code>
* and set back to false when the <code>List</code> dispatches
* <code>FeathersEventType.SCROLL_COMPLETE</code>. You may also need
* to set to false if the <code>isScrolling</code> property of the
* <code>List</code> is <code>true</code> before you listen to those
* events.</p>
*
* <p>In the following example, the image loader's texture creation is
* delayed:</p>
*
* <listing version="3.0">
* loader.delayTextureCreation = true;</listing>
*
* @default false
*
* @see #textureQueueDuration
* @see feathers.controls.Scroller#event:scrollStart
* @see feathers.controls.Scroller#event:scrollComplete
* @see feathers.controls.Scroller#isScrolling
*/
public function get delayTextureCreation():Boolean
{
return this._delayTextureCreation;
}
/**
* @private
*/
public function set delayTextureCreation(value:Boolean):void
{
if(this._delayTextureCreation == value)
{
return;
}
this._delayTextureCreation = value;
if(!this._delayTextureCreation)