6 Replies Latest reply on Jun 12, 2009 10:02 AM by garigantua

    Instances for Skin class

    garigantua Level 1

      Thank you all for the new release.  Skinning is proving to be highly factorable.  Is there any way to get an instance of the the skin classes for manipulation at runtime?  It looks like there are constructors, but I doesn't seem that the instances are correctly constructed using a "new" statement.  Is there anyway to refer to the skins instances instead of only skins classes ie skinClass:ClassReference(xxx.xxxxx)

        • 1. Re: Instances for Skin class
          rfrishbe Level 3

          You set the skin through the skinClass CSS Style.  You can get the skin instance that was created via the skin getter.  So you could ask for:

           

          myComponent.skin

           

          Just curious, but what type of manipulation do you plan on doing at runtime that you didn't want to put in the skinClass?

           

          Thanks,

          Ryan

          1 person found this helpful
          • 2. Re: Instances for Skin class
            garigantua Level 1

            rfrishbe,

             

            Thank you for your help.  I tried what you suggested, I was able to get an object instance from your suggestion.  However, it is typed as a Skin class, (static type spark.components.supportClasses:Skin) .  I was hoping for an instance to manipulate like in the IEffectInstance classes, and to be able to access the properties that way.  I was thinking about experimenting with user defined skinning.  With the type Skin class, it would be much harder to do than I thought. 

             

            g

             

             

            • 3. Re: Instances for Skin class
              rfrishbe Level 3

              The "skin" property should give you the instance of that skin.  You should be able to do something like:

               

              myComponent.skin.numElements;

               

              If you want something else, and not the skin instance, let me know.  What are you trying to do exactly?

               

              -Ryan

              • 4. Re: Instances for Skin class
                David_F57 Level 5

                The following code is a quick and dirty way of creating a skin with dynamic(runtime) properties if that is what you are looking for

                 

                 

                 

                === dfExFrame.as

                package

                {   

                import spark.components.SkinnableContainer;

                 

                public class dfExFrame extends SkinnableContainer

                {

                [Bindable] public var FrameOuter : uint = 0x000000;

                [Bindable] public var FrameInner : uint = 0x777777;

                [Bindable] public var InsertUpper: uint = 0xBBAABB;

                [Bindable] public var InsertLower: uint = 0x555555;

                [Bindable] public var RadiusOuter: int = 0;

                [Bindable] public var RadiusInner: int = 10;

                [Bindable] public var hasCaption : Boolean = true;

                [Bindable] public var Caption: String = 'Caption';

                 

                public function dfExFrame()

                {

                super();

                }

                 

                public function SwapFrame(): void

                {

                var tmp: uint;

                tmp = FrameOuter;

                FrameOuter = FrameInner;

                FrameInner = tmp;

                }

                 

                public function SwapInsert(): void

                {

                var tmp: uint;

                tmp = InsertUpper;

                InsertUpper = InsertLower;

                InsertLower = tmp;

                }

                 

                public function SetCaption(title:String,show:Boolean=true): void

                {

                hasCaption = show;

                if (title.length > 0) Caption=title else Caption='';

                 

                }

                 

                 

                }

                }

                 

                 

                === dfText.xmxl

                 

                <s:SparkSkin name="dfText"

                xmlns:fx="http://ns.adobe.com/mxml/2009"

                xmlns:s="library://ns.adobe.com/flex/spark"

                xmlns:local="*">

                 

                <fx:Metadata>

                [HostComponent("dfExFrame")]

                </fx:Metadata>

                 

                <s:states>

                <s:State name="normal"/>

                </s:states>

                 

                <s:Rect radiusX="{hostComponent.RadiusOuter}" radiusY="{hostComponent.RadiusOuter}" left="0" right="0" top="0" bottom="0" rotation="90">

                <s:fill>

                <s:LinearGradient>

                <s:entries>

                <s:GradientEntry color="{hostComponent.FrameOuter}" />

                <s:GradientEntry color="{hostComponent.FrameInner}" />

                <s:GradientEntry color="{hostComponent.FrameOuter}" />

                </s:entries>

                </s:LinearGradient>

                </s:fill>

                </s:Rect>

                 

                <s:Rect radiusX="{hostComponent.RadiusInner}" radiusY="{hostComponent.RadiusInner}" left="4" right="4" top="4" bottom="4" rotation="90">

                <s:fill>

                <s:LinearGradient>

                <s:entries>

                <s:GradientEntry color="{hostComponent.InsertUpper}"/>

                <s:GradientEntry color="{hostComponent.InsertLower}"/>

                </s:entries>

                </s:LinearGradient>

                </s:fill>

                </s:Rect>

                  <s:SimpleText left="7" right="7" top="4" bottom="4" verticalAlign="middle" textAlign="center" text="{hostComponent.Caption}"

                  visible="{hostComponent.hasCaption}" fontStyle="italic" fontWeight="bold"/>

                <s:Group id="contentGroup" left="5" right="5" top="5" bottom="5"/>

                 

                </s:SparkSkin>

                • 5. Re: Instances for Skin class
                  emphasized

                  Try this:

                   

                  (mySparkComp.skin as CustomSkin).customProperty = "whatever";

                   

                  Cheers~

                  • 6. Re: Instances for Skin class
                    garigantua Level 1

                    HA!  Thank you very much!  That was the ticket!  Have a great day!