0 Replies Latest reply on Mar 14, 2013 4:04 AM by FM_Flame

    [Flex4.6] Why itemCreationPolicy immediate doesn't work on spark Form?

    FM_Flame Level 1

      I have something simple this below. The problem is that the form itself is created which is perfect but it's form items and it's form items` items are not.

      I am expecting that when I define itemCreationPolicy for a parent container to have it applied for it's children as well. This is not the case here and I've tried many things like adding the same properties to the skin contentGroup of the form and the layout and setting creationPolicy of the form to all but all in vain.

      The only way to make it work was to manually add includeIn="immediateState" itemCreationPolicy="immediate" to every single child of the form, in this case: formItem and button. But if you have a huge form those are many lines of code I would like to avoid. And I actually did with createDefferedContent(). But you still have to call it twice - first for the formItem with form.createDefferedContent() and then for the button with formItem.creatreDefferedContent().

       

      This is definitely far from ideal. Does anyone know a better solution - possibly a property on the parent container that would pass to all the children ?

       

      Or maybe this is a bug, possible fixed in a newer version of the framework? Anyone have an idea?

       

       

      <s:Application creationComplete="ccHandler(event)">

       

      <fx:Script>

       

           protected function ccHandler(event:FlexEvent):void {

                trace(form); // form

                trace(formItem); // null

                trace(button); // null

           }

       

      </fx:Script>

       

      <s:States>

           <s:State name="default" />

           <s:State name="immediateState" />

      </s:States>

       

      <s:Form id="form" includeIn="immediateState" itemCreationPolicy="immediate">

           <s:FormItem id="formItem">

                <s:Button id="button" />

           </s:FormItem>

      </s:Form>

       

      </s:Application>