title: Flex access variable from one component into another
body: <p>I have a main application which has an int variable declared. I want to access this variable in another component which is present in another package. How can I do this?</p>
  
  <p>Main.mxml (default package)</p>
  
  <pre><code>&lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                         xmlns:s="library://ns.adobe.com/flex/spark" 
                         xmlns:mx="library://ns.adobe.com/flex/mx"
                                 preinitialize = "foo()"&gt;
      &lt;fx:Script&gt;
              &lt;![CDATA[
                           public var value1:int;
                           public function foo():void {
                              value1 = 5;
                           }
  
                  ]]&gt;
          &lt;/fx:Script&gt;
  
      &lt;\s:Application&gt;
  </code></pre>
  
  <p>Comp.mxml (components package)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx"
                   creationcomplete = "foo2()"&gt;
             &lt;fx:Script&gt;
                  &lt;![CDATA[
                              public function foo2(): void{
                               //------&gt; access value1 from Main.mxml here.
                              }
  
                      ]]&gt;
              &lt;/fx:Script&gt;
  
  &lt;/s:Group&gt;
  </code></pre>