2 Replies Latest reply on Dec 1, 2010 9:59 AM by foolish3737

    Send parameters into a components skinClass?

    foolish3737

      I have a component that has a custom skinClass applied to it. Is it possible to access the skinClass and send params to it?

        • 1. Re: Send parameters into a components skinClass?
          Shongrunden Adobe Employee

          Are you looking for the skin property?

           

          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                         xmlns:s="library://ns.adobe.com/flex/spark">
              <fx:Script>
                  <![CDATA[
                      import spark.skins.spark.ApplicationSkin;
                      protected function button1_clickHandler(event:MouseEvent):void
                      {
                          var mySkin:ApplicationSkin = this.skin as ApplicationSkin;
                          trace(mySkin.width);
                      }

                  ]]>
              </fx:Script>
              <s:Button label="inspect skin" click="button1_clickHandler(event)" width="100%" />
          </s:Application>
          • 2. Re: Send parameters into a components skinClass?
            foolish3737 Level 1

            Thanks for the reply Shon,

            I actually did get this resolved in a different fashion that works quite well.

             

            I just used custom events that are dispatched from or to the List/Grid/etc...

             

            Within my itemRenderer I added a listener to the 'owner' component:

             

            var ow:List = owner as List;
            ow.addEventListener(CustomEvent.CustomEventWithParams, onCustomEvent);
            

             

            then, elsewhere in the application I created my custom event and dispatched it from the 'owner' (aka List):

             

            //params object is passed in with my custom event
            var params:Object = new Object();
            params.message = "this data is now in my itemRenderer
            var evt:CustomEvent = new CustomEvent(CustomEvent.CustomEventWithParams, params);
            //dispatch the event from the 'owner' (aka List)
            ownerList.dispatchEvent(evt);
            

             

            This works both ways. I can add a listener to the List and dispatch events from the itemRenderer instead. :-)