Actionscript 3 Flex:如何控制表单项和相应的errorString之间的间距?
下面是一个简单的应用程序来说明我的问题。说明:Actionscript 3 Flex:如何控制表单项和相应的errorString之间的间距?,actionscript-3,apache-flex,flex4,Actionscript 3,Apache Flex,Flex4,下面是一个简单的应用程序来说明我的问题。说明: 运行附带的Flex4代码 在第一个表单项中输入0(例如“输入速度(MPH)”) 单击第二个表单项 请注意,错误字符串出现在第一个表单项的右侧 问题:如何使错误字符串直接显示在第一个表单项的右侧,同时保持表单的宽度不变(例如,当前示例使用的固定表单宽度为400 px) 1e11){ speedId.errorString=“速度不能超过100 MPH。”; 返回; } } ]]> 您可以通过定制FormItemSkin来控制错误消息的
1e11){
speedId.errorString=“速度不能超过100 MPH。”;
返回;
}
}
]]>
您可以通过定制FormItemSkin
来控制错误消息的位置
下面是默认FormItemSkin
类的一些片段。请注意,此外观使用“约束”列/行来排列各个零件。您可以修改列的定义,也可以修改错误消息在“helpColumn”中的位置。有很多其他的方法可以解决这个问题,但是看起来你需要在皮肤内部这样做
约束列/行声明:
<s:layout>
<s:FormItemLayout>
<s:constraintColumns>
<!--- The column containing the sequence label. -->
<s:ConstraintColumn id="sequenceCol" />
<!--- The column containing the FormItem's label. -->
<s:ConstraintColumn id="labelCol" />
<!--- The column containing the FormItem's content. -->
<s:ConstraintColumn id="contentCol" width="100%"/>
<!--- The column containing the FormItem's help content. -->
<s:ConstraintColumn id="helpCol" maxWidth="200"/>
</s:constraintColumns>
<s:constraintRows>
<!--- @private -->
<s:ConstraintRow id="row1" baseline="maxAscent:10" height="100%"/>
</s:constraintRows>
</s:FormItemLayout>
</s:layout>
+1给出一个工作示例。。。它应该是+100!最近似乎出现了很多写得不好的问题:(@ggkmath我一直在考虑这个问题,表单似乎覆盖了元素的大小,以便对齐标签和表单元素。我得到的最好结果是在“contentCol”列上使用一个固定的宽度(宽度为100%).这不是一个很好的解决方案,也许可以在这种情况下b/c您的表单有一个固定的宽度。我认为有一个更好的答案,但您必须深入挖掘表单和表单项的布局逻辑。
<s:layout>
<s:FormItemLayout>
<s:constraintColumns>
<!--- The column containing the sequence label. -->
<s:ConstraintColumn id="sequenceCol" />
<!--- The column containing the FormItem's label. -->
<s:ConstraintColumn id="labelCol" />
<!--- The column containing the FormItem's content. -->
<s:ConstraintColumn id="contentCol" width="100%"/>
<!--- The column containing the FormItem's help content. -->
<s:ConstraintColumn id="helpCol" maxWidth="200"/>
</s:constraintColumns>
<s:constraintRows>
<!--- @private -->
<s:ConstraintRow id="row1" baseline="maxAscent:10" height="100%"/>
</s:constraintRows>
</s:FormItemLayout>
</s:layout>
<s:RichText id="errorTextDisplay" includeIn="errorStates"
fontStyle="italic" fontWeight="normal" color="0xFE0000"
left="helpCol:27" right="helpCol:10"
bottom="row1:10" baseline="row1:0"
maxDisplayedLines="-1"/>