3 Replies Latest reply on Jan 2, 2011 6:48 PM by Gregory Lafrance

    viewstate component creation policy .

    acehema

      Hi ,

       

      I am creating a cover flow component , the one very similar to the example given in tour de flex. I see some start up delay . I thought of using states to show a screen with a spinner until the coverflow component got created . Hence  , I set the currentstate="normalstate" at the creationcomplete of coverflow component and showed another panel with a spinner in it have state as "loadState" which is the default state . But I see that , the creation complete event of coverflow is not called as the component is not currently visible . I tried giving itemcreationpolicy to "immediate" but it seems Flex is not creating components for all view states . It just creates components that are visible in the default load state ( which is the panel with spinner in my case ) . Is there any way to specify creation of all components for all view states ? ( I tried creationpolicy = all too , doesn't seem to work )

        • 1. Re: viewstate component creation policy .
          acehema Level 1

          Hi ,

           

          I created a sample of what I need if my question is not clear . is it possible for creationcomplete methods of both panels to be called during application startup ? currently , only the creationcomplete method of first panel gets called .

           

          <?xml version="1.0" encoding="utf-8"?>
          <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" minWidth="955" minHeight="600" creationPolicy="all">
              <fx:Declarations>
                  <!-- Place non-visual elements (e.g., services, value objects) here -->
              </fx:Declarations>
             
              <s:states>
                  <s:State name="loadState"/>
                  <s:State name="afterLoadState"/>
              </s:states>
             
              <fx:Script>
                  <![CDATA[
                 
                      private function first():void
                      {
                          trace(" first panel ");               
                      }
                      
                      private function second():void
                      {
                          trace(" second panel  ");
                      }
                     
                  ]]>
              </fx:Script>
             
              <s:Panel width="239" height="308" title="One" includeIn="loadState" x="62" y="37" creationComplete="first()" click="currentState='afterLoadState'"/>
             
              <s:Panel width="239" height="308" title="two" id="paneltwo" includeIn="afterLoadState" itemCreationPolicy="immediate" x="327" y="40" creationComplete="second()"/>
             
          </s:Application>

          • 2. Re: viewstate component creation policy .
            Rgrommel

            I'm not sure exactly what you are wanting to do, but it sounds like you want the panels to be around for both states, but only visible in one.  If this is the case, instead of using includeIn, you might want to just set the visibility dependent on the state.  For example:

             

             

            <s:Panel width="239" height="308" title="two" id="paneltwo" visible.afterLoadState="true" visible.loadState="false" x="327" y="40" creationComplete="second()"/>

             

            Message was edited by: Rgrommel

            • 3. Re: viewstate component creation policy .
              Gregory Lafrance Level 6

              I think you're better off with a preloader.

              1 person found this helpful