1 Reply Latest reply on Aug 10, 2009 10:53 AM by Shongrunden

    can you have 2 application components in one project??

    cyber0897 Level 1

      hey guys... im brand new to flex, but i was wondering if you could have 2 application components in one project??

       

      for example...

      in my login.mxml

       

      i would have

      <s:Application ...... >

       

      in here i would have states, state one will first show my login screen,

      and then on login success it will display my main mxml...

       

      </s: Application>

       

       

      the other file i have

      main.mxml

      <s:Application .... >

       

      here i have all my main data....

       

      </s: Application >

        • 1. Re: can you have 2 application components in one project??
          Shongrunden Adobe Employee

          You should really only have one Application object in your Flex application.  A better approach is to base your custom components off of the Group component.

           

          So your main.mxml file will have something like:

          <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/halo"
              xmlns:comps="*">
          
              <comps:LoginScreen />
              
          </s:Application>
          

           

          And your LoginScreen custom component (LoginScreen.mxml) could be based off of a spark Group:

           

          <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/halo">
          
              <s:SimpleText text="hello" />
              <s:Button label="Login" x="100" />
              
          </s:Group>
          

           

          In this case both your main.mxml and LoginScreen.mxml files should be in the same directory.  If you want to put the LoginScreen.mxml file in a subfolder you can update the path on the comps namespace to something like xmlns:comps="subfolder.*"