Hi everyone and thanks for reading my question. I have a class named Box. I want to display all the properties in Window->Output or CTRL+ENTER. I use actionscript 2.
I’m trying this code: (using for -in statement in a class)
class Box {
public static var maxWidth:Number = 250;
public static var maxHeight:Number = 250;
}
// avec for on listes toutes les proprietes de la classe Box
// on liste les valeurs des dates membre de la classe Box avec for-in
for (var prop:String in Box)
{
trace("propriete nom: " + prop);
trace("propriete valeur: " + Box[prop]);
}
I want to return this on pressing CTRL+ENTER: (my desired output)
propriete nom: maxHeight
propriete valeur: 250
property nom: maxWidth
property valeur: 250
But I have this error on running my code:
Classes may only be defined in external ActionScript 2.0 class scripts.
I put for-in in the exterior of class Box but without result.
How can I correct my code to display the thing I want?
Also I have the same error on this dynamic class Box:
dynamic class Box {
public var width:Number = 15;
public var height:Number = 15;
}
// Creation d'une instance
var b:Box = new Box( );
// ajout de la propriete dynamique de l'instance
b.newProp = "hello world";
// enumeration des proprietes
for (var prop in b) {
trace("propriete nom: " + prop);
trace("propriete valeur: " + b[prop]);
}
Desired output:
//propriete nom: newProp
//propriete valeur: hello world
Error received in output :
Classes may only be defined in external ActionScript 2.0 class scripts.
How can I correct my 2 codes to solve that conflicting error in this 2 cases?