[英]Set property of NumericStepper declared as UIComponent
I have a NumericStepper declared as a UIComponent: 我有一个NumericStepper声明为UIComponent:
<![CDATA[
private var component:UIComponent;
component = new NumericStepper();
]]>
I need to change the .maximum value of the NumericStepper but due to the UIComponent not having a .maximum property the following code fails with the error: 1119: Access of possibly undefined property maximum through a reference with static type mx.core:UIComponent . 我需要更改NumericStepper的.maximum值,但是由于UIComponent没有.maximum属性,因此以下代码失败,并显示以下错误: 1119:通过具有静态类型mx.core:UIComponent的引用访问最大未定义的属性 。
component.maximum = 11;
My question is how would I define a property in this scenario? 我的问题是在这种情况下如何定义属性?
Another solution you can use is "casting": 您可以使用的另一个解决方案是“广播”:
var component:UIComponent;
component = new NumericStepper;
(component as NumericStepper).maximum = 500;
This has compile-time checking, but i don't know if it has any "downsides" 这有编译时检查,但我不知道它是否有任何“缺点”
Hope this helps. 希望这可以帮助。
You can define it using the dynamic/string syntax: 您可以使用动态/字符串语法来定义它:
component["maximum"] = 11;
I use that a lot, the only downsides are: 我经常使用它,唯一的缺点是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.