You create dynamic classes by using the dynamic attribute when you declare a class. For example, the following code creates a dynamic class named "DynamicClass".
Code : /*Main.as*/
package
{
import flash.display.Sprite;
public class Main extends Sprite
{
public function DynamicClassCode()
{
var dClass:DynamicClass = new DynamicClass();
dClass.age = 25; // Dynamically add new variable.
// Dynamically add new Method.
dClass.getDetails = function():void
{
trace(dClass.nama);
trace(dClass.age);
}
dClass.getDetails(); // Method call
}
}
}
dynamic class DynamicClass
{
public var nama:String = "Abdul";
}
No comments:
Post a Comment