Hi,

Here is the simple example for test case.

In this example;

When you click on the button, the state is switched between two states : loggedOutState/loggedInState.

And according to the state definition the form is shows and hides according to the state.

The button "nevershown" is never shown because it is excluded from both states loggedOutState/loggedInState.

The one which is strange is the form item "button1". It has the same state with the button "nevershown" ,  but behaves like it has no excludeFrom tag defined. It behaves similar when you use "includeIn" tag.

I am going to debug the code and try to find-out what is wrong, but if anybody has any solution and/or idea I highly appreciate.

Thank,
Serkan

Sample test case code

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
         xmlns:s="library://ns.apache.org/royale/spark"
         xmlns:mx="library://ns.apache.org/royale/mx"
         paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0"
         height="100%" width="100%"
         creationComplete="onCreationComplete()"
         >

    <fx:Metadata>
    </fx:Metadata>

    <s:states>
        <s:State name="loggedOutState"/>
        <s:State name="loggedInState"/>
        <s:State name="jobDetailState"/>
    </s:states>

    <fx:Script>
        <![CDATA[

            import mx.formatters.DateFormatter;
            import org.apache.royale.utils.Timer;

            [Bindable]
            var time:String;

            private var ticker:Timer;

            [Bindable]
            private var counter:Number = 0;

            protected function button_clickHandler(event:MouseEvent):void {
                if(currentState == "loggedOutState") {
                    currentState = "loggedInState";
                } else if(currentState == "loggedInState") {
                    currentState = "loggedOutState";
                }
            }

            public function showTime():void {
                ticker = new Timer(1,1);
                ticker.addEventListener(Timer.TIMER, onTimerComplete);
                ticker.start();

                COMPILE::JS
                    {
                        var d = new Date();
                        time = d.toLocaleTimeString() + ' ' + d.toLocaleDateString();

                    }
            }

            public function onCreationComplete():void {
                showTime();
            }

            public function onTimerComplete(event:Timer):void {
                showTime();
                counter ++;
            }


        ]]>
    </fx:Script>

    <fx:Declarations>
    </fx:Declarations>

    <s:layout>
        <s:VerticalLayout gap="10" paddingRight="10" paddingLeft="10" paddingTop="10" paddingBottom="20" />
    </s:layout>

    <s:Button id="button" width="200" label="Show/Hide" click="button_clickHandler(event)"/>

    <mx:Panel title="Form Container Example"
              paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10"
              height="100%" width="100%">

        <mx:Text width="100%"
                 text="Moving from one form field to another triggers the validator."/>

        <mx:Form width="100%" height="100%" excludeFrom="loggedOutState" >
            <mx:FormHeading label="Enter values into the form."/>

            <mx:FormItem label="First name" >
                <mx:TextInput id="fname" width="200"/>
            </mx:FormItem>

            <mx:FormItem label="Date of birth (mm/dd/yyyy)">
                <mx:TextInput id="dob" width="200"/>
            </mx:FormItem>

            <mx:FormItem excludeFrom="loggedOutState,loggedInState" >
                <s:Button id="button1" width="200" label="Time : {time}" />
            </mx:FormItem>


        </mx:Form>

    </mx:Panel>

    <s:Button id="nevershown" excludeFrom="loggedOutState,loggedInState" label="Never Shown Button" />

</s:Application>

Reply via email to