Problems in Flash #03: Bad Compiler OO Design

POSTED IN Actionscript, Flash Platform | TAGS : , , , July 6, 2008

I spent an hour trying to figure out a certain bug in my application.  As a habit from a previous job, when I can, I always prefix the function input variable with an underscore (ie. ‘function(_message:String)’) to make it apparent that this is in fact an input variable.

However, I was wondering why when I was trying to use the input variable ‘_url’, my application kept failing with a weird error.  I was trying to pass in an internet address, but it kept trying to open it on a local address.  It became apparent to me that the compiler wasn’t using the input variable, but instead was using the global variable ‘_url’ which depicts where the current movie resides (ie. ‘C:\myFlashApp\app.swf’) .

This confused me greatly because if you’re using any other coding language, the variable scope when compiling always goes Function Variable -> Input Variable -> Class Variable -> Global Variable.  In this case, it went directly to the global variable which I didn’t even know existed since I never used it.  It appears that all global variables are like this.  Global variables are just that, global variables; they should be accessed by using a keyword (ie. ‘_global’) and not be treated like a reserved word where you can’t use it at all.  This really rubs me in the wrong way.  This is just bad design by any standard and someone should suffer the consequence.  I guess a beating with a proper software design book isn’t enough, I think we need to resort to the proper design axe.

Loading