开发者

Cannot access constant through itemRenderer using parentDocument

开发者 https://www.devze.com 2023-02-05 12:48 出处:网络
I have an itemRenderer inside a dataGrid, and I am able to access variables on the mxml file (in a *.as script file referenced from the mxml) using parentDocum开发者_开发百科ent. However, I am unable

I have an itemRenderer inside a dataGrid, and I am able to access variables on the mxml file (in a *.as script file referenced from the mxml) using parentDocum开发者_开发百科ent. However, I am unable to access a constant in the same script file. If I change the constant to a regular var, I can access it.

I created a getter function for the constant and it works, but why can't the constant be accessed directly?

Thanks


Constants are generally static, and therefore access via the class. Getters / Setters are members, and therefore accessed via an instance.

Therefore, to get access to a constant, you need to have an explicit reference to the class.

Something like parentDocument.MY_CONSTANT wouldn't work, however MyClass(parentDocument).MY_CONSTANT would.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号