Sravan0313
Sravan0313

Reputation: 83

how to create a AS3 dynamic class and how to use it?

What is a dynamic class and what are its uses and how to create and use a dynamic class?

Can anyone guide me to a good tutorial please?

Upvotes: 1

Views: 6084

Answers (2)

Manish
Manish

Reputation: 3522

A dynamic class is basically one that can be modified at runtime. One of the main uses of this feature is when extending the Proxy class.

A couple of good examples:

http://manishjethani.com/archives/2008/08/25/jsonobject-for-reading-and-writing-json-in-actionscript http://manishjethani.com/archives/2008/12/19/guaranteeing-enumeration-order-in-for-in-loops

Upvotes: 1

turbosqel
turbosqel

Reputation: 1542

Here You can find basic info : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/statements.html#dynamic

Dynamic class allow You to add additional dynamic params to object in run-time .

For example : Sprite isnt dynamic , so You cannot do thing like :

var sprite:Sprite = new Sprite ();
sprite["value"] = 10; // this will throw ReferenceError

But MovieClip is dynamic instance that allow You to add dynamic params :

var mclip:MovieClip = new MovieClip();
mclip["value"] = 10;

To make class instance dynamic , You have to add 'dynamic' key word to declaration :

public dynamic class MyClass { ...

Upvotes: 8

Related Questions