dynamic class Box { // defining class named Box
public var width:Number = 15; // data members width and height definition
public var height:Number = 15;
}
// creating instance
var b:Box = new Box( );
// add dynamically the property of the instance
b.newProp = "hello world";
// enumerating properties
for (var prop in b) {
trace("propriete nom: " + prop);
trace("propriete valeur: " + b[prop]);
}
I want to obtain this as an output:
//propriete nom: newProp
//propriete valeur: hello world
I receive the same error as in this topic:
The error is:
Classes may only be defined in external ActionScript 2.0 class scripts.
I read this article from here:
http://www.kirupa.com/developer/oop2/AS2OOPClassFileManage2.htm
I put the .fla and as file in the same directory and added it in ClassPath.
But still I receive that error.