# Dynamic class - little problem

**URL:** https://forum.kirupa.com/t/dynamic-class-little-problem/295899
**Category:** Uncategorized
**Created:** [September 7, 2009, 6:50am UTC](https://forum.kirupa.com/t/dynamic-class-little-problem/295899 "2009-09-07T06:50:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![mihaispr](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mihaispr](https://forum.kirupa.com/u/mihaispr)
#### Post date: [September 7, 2009, 6:50am UTC](https://forum.kirupa.com/t/dynamic-class-little-problem/295899/1 "2009-09-07T06:50:51Z")

</div>

```auto

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:

> **[Working with classes - POO in Actionscript 2](https://www.kirupa.com/forum/showthread.php?t=334558)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

The error is:

```auto
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](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.
