flex - Issue with both red and blue colors with validator and errorString of textinput -


i'm facing strange issue flex , validator.

here code:

testmain.xml

<?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">  <fx:script>     <![cdata[         import mx.controls.alert;         import mx.validators.stringvalidator;          import utils.validableproperty;          [bindable] public var nameid:validableproperty;          public function start():void {             var nameidvalidator:stringvalidator = new stringvalidator();             nameidvalidator.required = true;             nameidvalidator.maxlength = 35;             nameid = new validableproperty(nameidvalidator);             nameid.validate();         }     ]]> </fx:script>  <s:applicationcomplete>     start(); </s:applicationcomplete>  <s:minheight>600</s:minheight> <s:minwidth>955</s:minwidth>  <mx:form color="0x323232" paddingtop="0">     <s:label text="see strange behavior of errorstring during validator operation validate."/>     <mx:formitem label="name">         <mx:textinput id="nameinput" width="300" errorstring="@{nameid.errormessage}" text="@{nameid.value}"/>     </mx:formitem> </mx:form> 

validableproperty.as

package utils {     import flash.events.eventdispatcher;     import mx.events.propertychangeevent;     import mx.events.validationresultevent;     import mx.validators.validator;      public class validableproperty extends eventdispatcher     {         [bindable]         public var value:object;          private var validator:validator;          [bindable]         public var isvalid:boolean;          [bindable]         public var errormessage:string;          private var statuschangehandler:function;          public function validableproperty(validator:validator, statuschangehandler:function=null,                                           target:ieventdispatcher=null) {             super(target);              this.validator = validator;             this.statuschangehandler = statuschangehandler;              this.addeventlistener(propertychangeevent.property_change, propertychangehandler);         }          private function propertychangehandler(evt:propertychangeevent):void {             if (evt.property == "value") {                 this.validate();             }         }          public function validate():void {             var result:validationresultevent = this.validator.validate(this.value);             this.isvalid = (result.type == validationresultevent.valid);             if (isvalid) {                 this.errormessage = null;              }             else {                 this.errormessage = result.message;             }             if (statuschangehandler != null)                 statuschangehandler();         }          public function set required(required:boolean):void {             if (validator == null)                 return;             validator.required = required;         }     } } 

when execute simple code, when writing value, example "a", errormessage value "this field required" disappear red color on inputtext border still there blue color.

when deleting value, time blue color there red 1 (cannot reproduce time) , error message "this field required".

what missing here? bug in flex? cannot have both of red , blue colors on textinput border.

i using eclipse flex sdk 4.5.0 (build 20967)

this not bug in flex. bug how you're coding all. if follow example in documentation, work.

<?xml version="1.0" encoding="utf-8"?> <!-- simple example demonstrate stringvalidator. --> <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">      <fx:declarations>         <mx:stringvalidator source="{nameinput}" property="text"                  tooshorterror="this string shorter minimum length of 4. "                  toolongerror="this string longer maximum allowed length of 35."                  minlength="4" maxlength="35"/>     </fx:declarations>  <s:form>     <s:formitem label="name">         <s:textinput id="nameinput" width="300" text="{nameid.value}"/>     </s:formitem> </s:form>  </s:application> 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -