Updated Branches:
  refs/heads/develop 1f85dd80c -> 3947a3a87

FLEX-33728 fixed so compiles and all supported version of flash and chache 
first answer


Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/becd0022
Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/becd0022
Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/becd0022

Branch: refs/heads/develop
Commit: becd0022b5204d2e0e4bf2ff16fff2f9fc2a0796
Parents: 1f85dd8
Author: Justin Mclean <[email protected]>
Authored: Mon Sep 16 09:51:23 2013 +1000
Committer: Justin Mclean <[email protected]>
Committed: Mon Sep 16 09:51:23 2013 +1000

----------------------------------------------------------------------
 .../spark/src/spark/primitives/BitmapImage.as   | 61 +++++++++++++++++---
 1 file changed, 52 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/becd0022/frameworks/projects/spark/src/spark/primitives/BitmapImage.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/spark/src/spark/primitives/BitmapImage.as 
b/frameworks/projects/spark/src/spark/primitives/BitmapImage.as
index 0a66e24..67e80b8 100644
--- a/frameworks/projects/spark/src/spark/primitives/BitmapImage.as
+++ b/frameworks/projects/spark/src/spark/primitives/BitmapImage.as
@@ -39,7 +39,6 @@ import flash.geom.Rectangle;
 import flash.net.URLRequest;
 import flash.system.ApplicationDomain;
 import flash.system.Capabilities;
-import flash.system.ImageDecodingPolicy;
 import flash.system.LoaderContext;
 import flash.utils.ByteArray;
 
@@ -223,6 +222,33 @@ public class BitmapImage extends GraphicElement
     private var sourceInvalid:Boolean;
     private var loadFailed:Boolean;
        private var dpiScale:Number = 1;
+       private var _cachedImageDecodePolicy:Boolean;
+       private var _haveCachedImageDecodePolicy:Boolean;
+       
+       
+       /**
+        *  Specifies that the image being loaded will be decoded when needed.
+        * 
+        *  @see flash.system.ImageDecodingPolicy
+        * 
+        *  @langversion 3.0
+        *  @playerversion Flash 10
+        *  @playerversion AIR 1.5
+        *  @productversion Flex 4.11
+        */
+       public static const ON_DEMAND:String = "onDemand";
+
+       /**
+        *  Specifies that the image being loaded will be decoded on load.
+        * 
+        *  @see flash.system.ImageDecodingPolicy
+        * 
+        *  @langversion 3.0
+        *  @playerversion Flash 10
+        *  @playerversion AIR 1.5
+        *  @productversion Flex 4.11
+        */
+       public static const ON_LOAD:String = "onLoad";
 
     //----------------------------------
     //  bitmapData
@@ -508,9 +534,11 @@ public class BitmapImage extends GraphicElement
     }
        
        /**
-        *  The image decoding policy, set to ImageDecodingPolicy.ON_DEMAND
-        *  or ImageDecodingPolicy.ON_LOAD.
-        *  The default is ImageDecodingPolicy.ON_DEMAND.
+        *  The image decoding policy, set to ON_DEMAND or ON_LOAD.
+        *  The default is ON_DEMAND.
+        * 
+        *  ImageDecodingPolicy also defined ON_DEMAND and ON_LOAD but these
+        *  are only available under AIR 2.6 and above.
         * 
         *  Setting to asynchronously decode and load the bitmap images for
         *  large image may improve your application’s perceived performance.
@@ -519,7 +547,7 @@ public class BitmapImage extends GraphicElement
         *  @playerversion AIR 2.6
         *  @productversion Flex 4.11
         */
-       public var imageDecodingPolicy:String = ImageDecodingPolicy.ON_DEMAND;
+       public var imageDecodingPolicy:String = ON_DEMAND;
 
     //----------------------------------
     //  preliminaryHeight
@@ -1495,6 +1523,21 @@ public class BitmapImage extends GraphicElement
             dpi = DensityUtil.getRuntimeDPI();
         return values.getSource(dpi);
     }
+       
+       
+       /**
+        * @private
+        * Returns true if current Flash Player/Air supports image decoding 
policy.
+        */
+       protected function 
hasImageDecodingPolicy(loaderContext:LoaderContext):Boolean {
+               // true for one it's true for all
+               if (!_haveCachedImageDecodePolicy) {
+                       _cachedImageDecodePolicy =  ("imageDecodingPolicy" in 
loaderContext);
+                       _haveCachedImageDecodePolicy = true;
+               }
+               
+               return _cachedImageDecodePolicy;
+       }
 
     /**
      *  @private
@@ -1531,8 +1574,8 @@ public class BitmapImage extends GraphicElement
             var loader:Loader = new Loader();
             var loaderContext:LoaderContext = new LoaderContext();
 
-                       if (imageDecodingPolicy in loaderContext)
-                               loaderContext.imageDecodingPolicy = 
imageDecodingPolicy;
+                       if (hasImageDecodingPolicy(loaderContext))
+                               loaderContext["imageDecodingPolicy"] = 
imageDecodingPolicy;
                                
             // Attach load-event listeners to our LoaderInfo instance.
             loadingContent = loader.contentLoaderInfo;
@@ -1560,8 +1603,8 @@ public class BitmapImage extends GraphicElement
         var loader:Loader = new Loader();
         var loaderContext:LoaderContext = new LoaderContext();
                
-               if (imageDecodingPolicy in loaderContext)
-                       loaderContext.imageDecodingPolicy = imageDecodingPolicy;
+               if (hasImageDecodingPolicy(loaderContext))
+                       loaderContext["imageDecodingPolicy"] = 
imageDecodingPolicy;
                
         loadingContent = loader.contentLoaderInfo;
         attachLoadingListeners();

Reply via email to