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

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


The following commit(s) were added to refs/heads/develop by this push:
     new 0a3955b  SparkRoyale: Add implementation of attachSkin which helps 
initialize properly components uses SkinnableComponent class to init skin
0a3955b is described below

commit 0a3955b4da689cf3ecbdcde5d5e131dd5ccd4806
Author: pzarzycki <piotr.zarzy...@wipro.com>
AuthorDate: Thu Dec 17 18:41:04 2020 +0000

    SparkRoyale: Add implementation of attachSkin which helps initialize 
properly components uses SkinnableComponent class to init skin
    
    ViewPort shouldn't add skin if it's already created
---
 .../spark/components/beads/SparkSkinViewport.as    |  5 +-
 .../supportClasses/SkinnableComponent.as           | 67 +++++++++++++++++++++-
 2 files changed, 70 insertions(+), 2 deletions(-)

diff --git 
a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SparkSkinViewport.as
 
b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SparkSkinViewport.as
index b5dc6df..b8af175 100644
--- 
a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SparkSkinViewport.as
+++ 
b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/beads/SparkSkinViewport.as
@@ -96,7 +96,10 @@ public class SparkSkinViewport extends EventDispatcher 
implements IBead, IViewpo
         var c:Class = ValuesManager.valuesImpl.getValue(value, "skinClass") as 
Class;
         if (c)
         {
-            host.setSkin(new c());
+            if (!host.skin)
+            {
+                host.setSkin(new c());
+            }
             host.skin.addEventListener("initComplete", initCompleteHandler);
             contentArea = host.skin; // temporary assigment so that 
SkinnableXXContainer.addElement can add the skin
         }
diff --git 
a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableComponent.as
 
b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableComponent.as
index b7083f2..19f5caa 100644
--- 
a/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableComponent.as
+++ 
b/frameworks/projects/SparkRoyale/src/main/royale/spark/components/supportClasses/SkinnableComponent.as
@@ -296,7 +296,72 @@ public class SkinnableComponent extends UIComponent
                        invalidateSkinState();
         dispatchEvent(new Event("skinChanged"));
     }
-    
+
+    /**
+     *  Create the skin for the component.
+     *  You do not call this method directly.
+     *  Flex calls it automatically when it calls 
<code>createChildren()</code> or
+     *  the <code>UIComponent.commitProperties()</code> method.
+     *  Typically, a subclass of SkinnableComponent does not override this 
method.
+     *
+     *  <p>This method instantiates the skin for the component,
+     *  adds the skin as a child of the component, and
+     *  resolves all part associations for the skin</p>
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    protected function attachSkin():void
+    {
+        // Class
+        if (!skin)
+        {
+            var skinClass:Class = getStyle("skinClass") as Class;
+
+            if (skinClass)
+                setSkin( new skinClass() );
+        }
+
+        if (skin)
+        {
+           // skin.owner = this;
+
+            // As a convenience if someone has declared hostComponent
+            // we assign a reference to ourselves.  If the hostComponent
+            // property exists as a direct result of utilizing [HostComponent]
+            // metadata it will be strongly typed. We need to do more work
+            // here and only assign if the type exactly matches our component
+            // type.
+            if ("hostComponent" in skin)
+            {
+                try
+                {
+                    Object(skin).hostComponent = this;
+                }
+                catch (err:Error) {}
+            }
+
+            // the skin's styles should be the same as the components
+          //  skin.styleName = this;
+
+            // Note: The Spark PanelAccImpl adds a child Sprite at index 0.
+            // The skin should be in front of that.
+            super.addChild(skin);
+
+            //skin.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE, 
skin_propertyChangeHandler);
+        }
+        else
+        {
+           // throw(new Error(resourceManager.getString("components", 
"skinNotFound", [this])));
+        }
+
+        findSkinParts();
+
+        invalidateSkinState();
+    }
+
     /**
      * @private 
      * 

Reply via email to