7 Replies Latest reply on Oct 27, 2009 1:29 AM by cksachdev

    Component property declaration in a Custom Component

    cksachdev Level 1

      Hello everyone,

      I have a question related to a custom component. I will define a use case and how I want to define a property.

      e.g.: I develop a custom component using Flex Library Project, with all manifest.xml, design.xml, locale etc. My component name is CustomList, now in this component, I define a property with following getter/setter.

      //-----------------------------------------------------------
      //  defaultState
      //-----------------------------------------------------------
      private var _defaultState:CustomState;


      [Bindable( "defaultStateChange" )]

      //I have tried defining type property as CustomState, doesn't works
      [Inspectable( category="General",  name="Default State" )]
      public function get defaultState():CustomState
      {
           return _defaultState
      }


      public function set defaultState( v:CustomState ):void
      {
           if ( _defaultState!= v)
           {
                _defaultState = v
                dispatchEvent(new Event("defaultStateChange"))
           }
      }


      Here, CustomState extends MXMLObjectAdapter and defines a id property and few other property. and In mxml I can define it like this,

      <CustomList ....>

           <defaultState>
                <CustomState label="" icon="" />
           </defaultState>

      </CustomList>


      Now, what I want to achieve is, I want to define property something like this:

      <CustomList ....>

           <defaultState label="" icon=""/>

      </CustomList>


      Can someone tell me how to achieve this and point me to some description about it.



      Thanks in advance.


      --

      Chetan Sachdev