0 Replies Latest reply on Jul 14, 2011 12:55 PM by Energetic Pixels

    SDK 4.5 Form Component and States

    Energetic Pixels

      I have created a s:Form component that will be used throughout my application. But FormItems are displayed depending on specific states of the main application file.  I left the s:states element and its s:State children in the main application and just moved the portion of the form that I wanted to become a component.  But I am getting State " " was referenced without being declared in my component mxml file.  When I move my s:states elements from my main application file over to my component mxml file, the form does not react correctly.

       

      So how do I get my form to correctly react to changing states in the main application???

       

      Tony

       

      States elements that are residing in my main application file:

      <s:states>
      
                <s:State name="home"  />
                <s:State name="searchMedia"  />
                <s:State name="smResults"  />
                <s:State name="lgResults"  />
                <s:State name="addMedia"  />
      
           </s:states>
      

      The above states are tied to "navigation" buttons that also live in the main application file.

       

      Here is the form component that I tried to create, but did not work ("Almost" only works in horseshoes and handgrenades):

      <?xml version="1.0" encoding="utf-8"?>
      <s:Form xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
                xmlns:mx="library://ns.adobe.com/flex/mx">
      
           <s:layout>
      
                <s:TileLayout clipAndEnableScrolling="true" orientation="rows"
                          paddingBottom="5" paddingTop="5"
                          paddingRight="5" paddingLeft="5"
                          columnAlign="justifyUsingWidth" verticalGap="6"  />
      
           </s:layout>
           <fx:Declarations>
      
                <!-- Place non-visual elements (e.g., services, value objects) here -->
           </fx:Declarations>
      
           <s:FormHeading label.addMedia="Add Media to Library" label.searchMedia="Search Library"  />
           <s:FormItem label="File Name:">
      
                <s:layout>
      
                     <s:HorizontalLayout  />
      
                </s:layout>
      
                <s:TextInput  />
                <s:Button includeIn="addMedia" label="Browse"  />
      
      
           </s:FormItem>
           <s:FormItem label="Course Contained In:">
      
                <s:TextInput  />
      
           </s:FormItem>
           <s:FormItem label="Keyword:">
      
      
                <s:TextInput  />
      
           </s:FormItem>
      
           <s:FormItem label="Type of Media (.jpg, .psd, etc):">
      
                <s:TextInput  />
      
           </s:FormItem>
           <s:FormItem label="Media size" includeIn="addMedia">
      
                <s:layout>
      
                     <s:HorizontalLayout  />
      
                </s:layout>
      
                <s:TextInput id="horizWidth"  />
                <s:Label text="(width) X "  />
                <s:TextInput id="vertWidth"  />
                <s:Label text="(height)"  />
      
           </s:FormItem>
           <s:FormItem label.searchMedia="Date (Range) Added:" label.addMedia="Date Added: ">
      
                <s:layout>
      
                     <s:HorizontalLayout  />
      
                </s:layout>
                <mx:DateField id="fromDate" includeIn="searchMedia"  />
                <mx:DateField id="toDate" includeIn="searchMedia"  />
                <mx:DateField id="dateAdded" includeIn="addMedia"  />
      
           </s:FormItem>
      
           <s:FormItem id="submitSearch" horizontalCenter="0">
      
                <s:Button bottom="5" label.searchMedia="Search"
                          label.addMedia="Submit" click="currentState='smResults'"
                          bottom.searchMedia="5" horizontalCenter.searchMedia="0"
                          bottom.addMedia="5" horizontalCenter.addMedia="0"  />
      
      
           </s:FormItem>
      
      </s:Form>
      
       
      

       

      Did I do something fundamentally wrong???