2 Replies Latest reply on Oct 24, 2006 7:24 AM by alanskinner

    prototype problem

    alanskinner Level 1
      Right I am using Actionscript v2.

      I simply want to add a prototype to String.

      so....


      String.prototype.printMe = function()
      {
      trace("me");
      }

      var t:String = "test";
      t.printMe();


      !!FAILS!!

      with:
      **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 11: There is no method with the name 'printMe'.
      t.printMe()

      Total ActionScript Errors: 1 Reported Errors: 1

      but if i change the line,

      var t:String = "test";

      to

      var t = "test";

      it works just fine.

      This is really weird, am i doing something obviously stupid here?

      Cheers guys!