1 Reply Latest reply on Mar 13, 2007 2:00 AM by BorosAdam

    strict data typing within an object

    DZ-015
      Hey. So - You've created an object. Now you want to have a property of the object - and you want that property to have strict data typing because you're picky. Here's the code you've written.

      var oTest:Object = new Object();

      oTest.nThing = new Number();
      oTest.nThing = 1;
      trace(oTest.nThing); // output = 1
      oTest.nThing = "word";
      trace(oTest.nThing); // output = word

      And there you run into a problem. You want the output of the second trace statement to be NaN / undefined. The variable within the object is not strictly typed. How do you fix this silly mistake you've made??

      :-p

      thanks!!

        • 1. Re: strict data typing within an object
          BorosAdam Level 1
          you can do it using object oriented programming. you have to use a custom class and inside the class you can define variables with strict data typing. for more information about creating custom classes refer to the flash help.
          about data types, object data type, organizing data in objects, classes, about object-oriented programming..., classes, writing custom class files... these are the topics you need to search for.

          adam