2 Replies Latest reply on Sep 27, 2010 3:46 AM by Anitha Selvaraj

    Can't pass custom properties to a Panel Component??

    RandomReado Level 1

      I'm trying to pass some custom properties to a Panel component but I keep getting Flex Error 1009 for no reason?! Anyone know why this is happening?

       

      // Main.mxml
      protected function initApp():void
      {
          var popup:MyPopUp = new MyPopUp();
          popup.labelText = 'This is a test';
      
          PopUpManager.addPopUp(popup, this, true);
      }
      

       

      // MyPopup.mxml
      <?xml version="1.0" encoding="utf-8"?>
      <s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx"
               title="Processing"
               cornerRadius="5">
          <fx:Script>
              <![CDATA[
                  import mx.managers.PopUpManager;
                  
                  private function close():void
                  {
                      PopUpManager.removePopUp(this);
                  }
                  
                  public function get labelText():String
                  {
                      return label.text;
                  }
                  
                  public function set labelText(s:String):void
                  {
                      label.text = s;
                  }
              ]]>
          </fx:Script>
          <s:controlBarContent>
              <s:Group width="100%">
                  <s:Button id="button" label="Close" click="close()" enabled="true" right="0" buttonMode="true" useHandCursor="true" width="50"/>
              </s:Group>
          </s:controlBarContent>
          <s:Label id="label" horizontalCenter="0" verticalCenter="0" paddingTop="20" paddingBottom="20" paddingLeft="20" paddingRight="20"/>
      </s:Panel>
      
        • 1. Re: Can't pass custom properties to a Panel Component??
          Anitha Selvaraj Level 2

          Change your code to something like this.

           

          <?xml version="1.0" encoding="utf-8"?>
          <s:Panel xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   title="Processing"
                   cornerRadius="5">
              <fx:Script>
                  <![CDATA[
                      import mx.managers.PopUpManager;
                     
                      [Bindable]
                      private var _labelText:String;
                     
                      private function close():void
                      {
                          PopUpManager.removePopUp(this);
                      }
                     
                      public function get labelText():String
                      {
                          return _labelText;
                      }
                      public function set labelText(s:String):void
                      {
                          _labelText = s;
                      }
                  ]]>
              </fx:Script>
              <s:controlBarContent>
                  <s:Group width="100%">
                      <s:Button id="button" label="Close" click="close()" enabled="true" right="0" buttonMode="true" useHandCursor="true" width="50"/>
                  </s:Group>
              </s:controlBarContent>
              <s:Label id="label" horizontalCenter="0" verticalCenter="0" paddingTop="20" paddingBottom="20" paddingLeft="20" paddingRight="20" text="{_labelText}"/>
          </s:Panel>

           

          Regards,

          Anitha

          • 2. Re: Can't pass custom properties to a Panel Component??
            RandomReado Level 1

            Thanks very much, that sorted it.