Skip navigation
Currently Being Moderated

How to pass skinclass to the custom component?

Apr 2, 2012 12:47 PM

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>

 
Replies
  • Currently Being Moderated
    Apr 2, 2012 1:47 PM   in reply to jerry98225

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points