5 Replies Latest reply on Oct 12, 2009 4:13 AM by jake_flex

    Is it possible to have private components inside a container?

    jake_flex Level 2

      Hi,

       

      I would like to hide some components inside a container, so that they could not be accessed from outisde. Same as declaring private variables in ActionScript. How can this be done in Flex?

       

      With the simple example component below, I would like the main app that uses this code to be only able to access the TextInput component via the function declared. Now, the TextInput can be accessed with both

       

      // a is instance of A
      a.ti.text;
      

      and

      a.text;
      
      <!-- Component A -->
      <mx:Canvas>
           <mx:TextInput id="ti" text="hello world!"/>
      
      <mx:Script>
           <![CDATA[
      
                public function get text() : void
                {
                     return ti.text;
                }
      
           ]]>
      </mx:Script>
      </mx:Canvas>