1 Reply Latest reply: Apr 2, 2012 1:47 PM by Claudiu Ursica RSS

    How to pass skinclass to the custom component?

    jerry98225 Community Member

      Hi guys, I am trying to pass skinClass from my main application to my custom component. The following is my code but it gave me error saying 'Initializer for'skinType': values of tpye spark.componets.supportClasses.Skin' cannot be represented in text.  I am not sure if it's possible to do it. Any thought? Thanks a lot.

       

      main.mxml

      <components:loginPanel id='loginPanel' horizontalCenter="33" verticalCenter="-15"

                                 skinType="skins.CustomPanel"

                                 loginButtonClick="loginpanel_loginButtonClickHandler(event)"/>

       

      loginPanel Component

      //script

      [Bindable]

      public var skinType:Skin;

       

      //mxml

      <s:Panel cornerRadius="5"

                   id='loginPanelComp'

                   x="32" y="8"

                   width="373" height="200"

                   title="Login in"

                   skinClass="{skinType}"

                   >

      ...............

      </Panel>

        • 1. Re: How to pass skinclass to the custom component?
          Claudiu Ursica Community Member

          You are trying to pass a string to match the value of a class. In SkinnableComponent skinClass property is a style.

          You should use css styles or if you want to set it runtime do something like

           

           

          private var _skinRef:Class;

           

          public function set skinClassRef(value:Class):void

                      {

                          _skinClassRef = value;

                          if (loginPanelComp)

                          {

           

                              loginPanelComp.setStyle(skinClass, skinRef);

                          }

                      }

           

          C