You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2019/11/21 09:11:24 UTC

[royale-asjs] 02/02: support non-CSS compliant backgroundAlpha in UIComponent. Should fix #566

This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit d14a4ab2649c01465cd8893e15e86e3ebe037f7a
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu Nov 21 00:49:04 2019 -0800

    support non-CSS compliant backgroundAlpha in UIComponent.  Should fix #566
---
 .../src/main/royale/mx/core/UIComponent.as         | 39 +++++++++++++++++++---
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
index d22549a..4d62f55 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -85,6 +85,7 @@ import org.apache.royale.html.beads.DisableBead;
 import org.apache.royale.html.beads.DisabledAlphaBead;
 import org.apache.royale.html.supportClasses.ContainerContentArea;
 import org.apache.royale.utils.PointUtils;
+import org.apache.royale.utils.CSSUtils;
 import org.apache.royale.utils.loadBeadFromValuesManager;
 
 import mx.validators.IValidatorListener;
@@ -4883,6 +4884,9 @@ COMPILE::JS
 		return value;
     }
 
+    private var _backgroundAlpha:Number = NaN;
+    private var _backgroundColor:String = null;
+    
     /**
      *  Sets a style property on this component instance.
      *
@@ -4902,13 +4906,38 @@ COMPILE::JS
      */
     public function setStyle(styleProp:String, newValue:*):void
     {
-        if (!style)
-            style = new FlexCSSStyles();
-        style[styleProp] = newValue;
+        if (styleProp == "backgroundAlpha")
+            _backgroundAlpha = Number(newValue);
+        else
+        {
+            if (styleProp == "backgroundColor")
+            {
+                if (typeof(newValue) === 'number')
+                    _backgroundColor = CSSUtils.attributeFromColor(newValue);
+                else
+                    _backgroundColor = String(newValue);
+            }
+            if (!style)
+                style = new FlexCSSStyles();
+            style[styleProp] = newValue;
+            COMPILE::JS
+            {
+                if (initialized)
+                {
+                    ValuesManager.valuesImpl.applyStyles(this, style);
+                }
+            }
+        }
         COMPILE::JS
         {
-        if (initialized)
-            ValuesManager.valuesImpl.applyStyles(this, style);
+            if (!isNaN(_backgroundAlpha) && _backgroundColor !== null)
+            {
+                var red:Number = parseInt("0x" + _backgroundColor.substring(1, 3));
+                var green:Number = parseInt("0x" + _backgroundColor.substring(3, 5));
+                var blue:Number = parseInt("0x" + _backgroundColor.substring(5, 7));
+                var rgba:String = "rgba(" + red + "," + green + "," + blue + "," + _backgroundAlpha + ")";
+                (element as HTMLElement).style['backgroundColor'] = rgba;
+            }                
         }
     }