0 Replies Latest reply on Jun 2, 2017 2:16 AM by Ibarim

    change skin on all instances of mx.Button with static var

    Ibarim Level 1


      I created class extending Button in mxml and this class has skin set to some flash picture from .swc.

      I would like to give users option to change look of the button. To do that I need to change skin of all instances of this button. I figured out that I'll create static function to change skin style. But of course it doesn't work

      In creationComplete event handler I attach the 'this' property to static var 'thisstatic'. Then when user changes option static functions are called inside my button class: test() and test2(). These functions should change skin by calling the 'thisstatic' var.  I tried setStyle, StyleManager and CSS styles, and nothing happens.

      I'm not sure if I made something wrong with the static/dynamic connection or changing skin dynamically is even possible, coz as far as I read forums it might not be possible at all.



      Example of my button class: (ButtonSkin is default mx button skin and btn_skin is my skin from .swc picture)


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



        skin="{btn_skin}" creationComplete="cc()">




      private function cc():void {

            thisstatic = this;



      private static var thisstatic:Button;

      public static function test():void {


      //each solution from below doesn't work




             //thisstatic.styleName = 'noskinstyle';



        public static function test2():void {


      //each solution from below doesn't work




             //thisstatic.styleName = 'skinstyle';





        @namespace s "library://ns.adobe.com/flex/spark";

        @namespace mx "library://ns.adobe.com/flex/mx";


        .noskinstyle {

        skin: null;



        .skinstyle {

        skin: btn_skin;