actionscript (flex): how to know whether a property of object exists (or defined)?

丶灬走出姿态 提交于 2019-12-04 00:20:50

Use something along the lines of

if (myObject.hasOwnProperty("propertyName"))

to check if the property exists.

Edit: Also take a look here.

BlueRaja - Danny Pflughoeft

hasOwnProperty() doesn't work correctly with inheritance, static properties, or dictionaries.

You should use

if ("propertyName" in myObject)

instead.

try

if ( obj["2008-02"] != null ) { then do something }

it is null, but you can't output null. you can also try converting it to a string for the purposes of a trace().

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!