3 Replies Latest reply on Oct 16, 2008 9:01 AM by kglad

    Dynamic Class

    tegnegi
      With Dynamic Classes you can add properties at run time. But the same can be done with Non Dynamic classes using their prototype property. For e.g. I've a Person Class for which the code is as follows:

      class Person {
      private var id:Number;
      function Person() {
      id = 007;
      }
      }

      Now is used this class in a fla file and make two instances

      var xx:Person=new Person()
      var yy:Person=new Person()

      trace(xx.__name) //undefined
      trace(yy.__name) //undefined

      Person.prototype.__name="myPersonClass"

      trace(xx.__name) //myPersonClass
      trace(yy.__name) //myPersonClass

      If this is true then whats the difference between dynamic and Non Dynamic classes coz using the prototype property we can convert every class into dynamic class.