0 Replies Latest reply on Oct 19, 2012 9:40 AM by rul987

    Override get width or height for just one component- Flex Mobile

    rul987

      Hi Everyone,

      Just a little background on what I am trying to do. I have a custom skin where I have a stylable text field to display the date. When clicking on the stylable text field, which is binded to the date, a date spinner comes up. Behind the datespinner I draw a sprite which needs to cover the whole screen so I can detect a click and make the datespinner go away.

      Now the problem-

      Without overriding the get width or get height I haven't been able to fill the whole screen. However when I do this the datespinner breaks because its getting the height from the override. Just wondering if anyone knew a way to override just one component and set all others to their default values. I know this might seem like a noob question and maybe I am missing something obvious, I am mostly new to as3.

      Here is some code-

      override protected function createChildren():void {

                  super.createChildren();

                 

                  if(!img) {

                      img = new dateButtonBG();

                      addChild(img);

                  }

                 

                  if (!maskSprite) {

                      maskSprite =  new Sprite();

                      maskSprite.graphics.beginFill(0xFFFFCC, .5);

                      maskSprite.graphics.drawRect(-((stage.height)/2),-((stage.width)/2), stage.width, stage.height);

                      maskSprite.graphics.endFill(); 

                  }

       

      if(!dateButton) {

                      dateButton = new StyleableTextField();

                      todayDate = new Date();

                      BindingUtils.bindProperty(dateButton, "text", date, "selectedDate");

                      dateButton.addEventListener(MouseEvent.CLICK, onDateButtonClick);

                      addChild(dateButton);

                  }

      invalidateDisplayList();

      }

       

      protected function removeSpinner( event:Event):void{

                  maskSprite.removeEventListener(MouseEvent.CLICK, removeSpinner);

                  removeChild(date);

                  removeChild(maskSprite);

                 

              }

       

      protected function onDateButtonClick (event:Event):void {

                  addChild(maskSprite);

                  addChild(date);

                  maskSprite.addEventListener(MouseEvent.CLICK, removeSpinner);

              }

       

      override public function get width () : Number {

                  return _width;

              }

             

      override public function get height () : Number {

                  return _height;

              }

       

      The code is not complete but is just for getting my point across. Thanks for reading and all your help.