Skip to main content
October 1, 2009
Question

Adding properties to an Object

  • October 1, 2009
  • 1 reply
  • 282 views

Hi,

I would wish to create a class extending Object class to create it's own properties in a FOR loop to save some space. However, it seems impossible...

The following won't work:

package com.sid1120.learning01
{
    import flash.utils.getDefinitionByName;
   
    public class CharacterAnimation extends Object
    {
        public function CharacterAnimation() {


            this["pingy"] = "Hello";
            trace(this["pingy"]);
           
        }
    }
}

On the other hand, this would work:

public function CharacterAnimation() {

            var object:Object = new Object();
             object["pingy"] = "Hello";
             trace(object["pingy"]);
            
         }

Is there a way around it so an object can create it's own properties using functions?

Thanks,

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
October 1, 2009

make your class dynamic.