Hi all,

Currently I'm working with a custom DateField, being a canvas with 2
states: "text" and "insert", and a public bindable property value:Date

the component:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";
     currentState="text"
     creationComplete="init()"
>

     <mx:Style>
         .vet { font-weight: bold; }
     </mx:Style>

     <mx:Script>
         <![CDATA[
             import mx.binding.utils.BindingUtils;
             //possible states
             public static var STATE_VIEW:String = "text";
             public static var STATE_INSERT:String = "insert";

             [Bindable]
             public var value:Date = new Date();

             private function init():void
             {
                 BindingUtils.bindSetter(function(arg:*):void{ value =
Date(arg as String); }, this, ["df", "text"]);
             }

         ]]>
     </mx:Script>

<mx:states>
     <!-- display the plain text //-->
     <mx:State name="text">
         <mx:AddChild>
             <mx:target>
                 <mx:HBox>
                     <mx:Text text="{this.label}" styleName="vet" />
                     <mx:Text text="{this.value}" />
                 </mx:HBox>
             </mx:target>
         </mx:AddChild>
     </mx:State>
     <!-- display the DateField as formitem //-->
     <mx:State name="insert">
         <mx:AddChild>
             <mx:target>
                 <mx:FormItem label="{this.label}">
                     <mx:DateField id="df" text="{this.value}"
editable="true" formatString="DD/MM/YYYY" firstDayOfWeek="1" />
                 </mx:FormItem>
             </mx:target>
         </mx:AddChild>
     </mx:State>
</mx:states>

</mx:Canvas>

Now in my app (simplified for this example)  I have 2 instances of this
component, one in inputState (id = in) and one in textState (id = view).
Next to them is a button which click-function is as follows:
public function setFilterText():void
{
         if (in.value as String == "")
             in.value = "(none)";
         view.value = in.value;
         //empty input
         in.value = null;
     }
}

Somehow this doesn't work, at all. Neither the value is passed on, nor
the inputDateField is set blank again.
Any thoughts?

--jeetee

Reply via email to