Object.prototype Crap

Actionscript:
  1. Object.prototype.myVar = "I am a variable";
  2.  
  3. var s:Sprite = new Sprite();
  4.  
  5. trace(Object(s).myVar);
  6.  
  7. var v:Video = new Video();
  8. trace(Object(v).myVar);

This.... should not be done... and setting myVar like this:

Actionscript:
  1. Object(s).myVar = "hello";

Will cause an error....

I keep a folder on my laptop for this website..... when I have a random snippet idea I put it in this folder.... Every couple of weeks I go through this folder and turn select snippets into posts.... when I rediscovered this snippet today it really made me laugh....

This entry was posted in Object, dynamic and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*