Ebates Coupons and Cash Back

My {Java} Academy

Learn java and related technologies

Some times we get this error in flex –

Reference error 1056 :Cannot create property myname on mycustomobject.

You will get this error if you are setting/accessing any property that dose not exist on any object which is not declared as dynamic.The base class ‘Object’ is a dynamic class.

What is dynamic class? – below declaration will make mycustomeobject as dynamic and allows addition/deletion of properties at runtime.

Public dynamic class mycustomeobject{

}

You can do –

mycustomeobject[‘prop1’] = value1;

Prop1 need not be present at compile time. Same statemne will give us this reference error if we do not declare that class as dynamic.

Also you can delete the properties at runtime-

delete mycustomeobject.prop1;

If you are planning to use dynamic objects, its always good you check property existance before you use it –

mycustomobject.hasOwnProperty(‘prop1’)

Hope this helps … Have fun!


Creative Commons License All posts published in this blog are licensed under a Creative Commons by-nc-sa 4.0 International License.

2009 - 2017 | Mixed with Foundation v5.5.1 | Baked with JBake v2.5.1 | Sitemap | Terms and Usage Policy