Object.prototype Crap

Object.prototype.myVar = "I am a variable";

var s:Sprite = new Sprite();
 
trace(Object(s).myVar);

var v:Video = new Video();
trace(Object(v).myVar);

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

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….

Leave a Reply

Your email address will not be published. Required fields are marked *