3 Replies Latest reply on Sep 25, 2012 8:26 PM by Flex harUI

    Adding component to spark form doesn't shows up.

    zubinshi

      I created an customized form that adding a label during construction and extends it to spark form.  If I created this form without any context it shows up ok, but if I create any formitem inside the form. the label is completely disappear. anyone know why?

       

      here is the example code for the customized form:

      package

      {

       

       

                import flash.events.Event;

                import flash.utils.describeType;

       

       

                import mx.binding.utils.BindingUtils;

                import mx.events.ValidationResultEvent;

                import mx.validators.Validator;

       

       

                import spark.components.Form;

                import spark.components.FormItem;

                import spark.components.Label;

                import spark.components.SkinnableContainer;

       

       

                public class ValidatingForm extends Form

                {

                          protected var myValidators:Array=[];

       

       

                          [Bindable]

                          public var formErrorMessage:String="invalida data";

       

       

                          public function ValidatingForm()

                          {

                                    super();

                                    addErrorMsgArea();

                          }

       

       

                          public function setFormErrorMsgVisible(visible:Boolean, msgKey:String=null):void

                          {

                                    if (visible)

                                    {

                                              formErrorMessage="invalida data";

                                    }

                                    else

                                    {

                                              formErrorMessage=null;

                                    }

                          }

       

       

                          protected function addErrorMsgArea():void

                          {

                                    var errorText:Label=new Label();

                                    BindingUtils.bindProperty(errorText, "text", this, "formErrorMessage");

                                    errorText.setStyle("color", "red");

                                    errorText.text="hello";

                                    errorText.percentWidth=100;

                                    addElement(errorText);

                          }

       

       

       

       

                }

      }

       

       

       

      ---------------------------------------