Effective ActionScript: variable testing

Uncategorized, JavaScript, ActionScript, Front-End Programming — Matas Petrikas on March 28, 2007 at 2:01 pm
It’s a pretty usual ActionScript code excerpt:
 if (variable == true){ doSomething(); }
as you can see, the variable value is being tested here against its true value, which is a totally redundant action. A much more convenient style would be:
 if (variable){ doSomething(); }
What so nice about this solution, that it can check any variable types for valid values. Both following tests work identically :
 
var variable:Number = null;
if (variable){ doSomething(); }
 
var variable:String = undefined;
if (variable){ doSomething(); }

Soft-hyphen, &Shy and word-wrapping problem solutions

Uncategorized, CSS, (X)HTML, Front-End Programming — Matas Petrikas on February 16, 2007 at 4:27 pm
If you’ve ever written CSS for a bigger website in some European language (other than English), you’ll know this problem: your have built all the templates for a huge project, everything works perfect in all possible font-sizes and viewport-widths, even in the “bad” browsers, and then you get a call from your PM - he’s looking at the test version on development server and your layout seems to be “broken”… What do you mean by “broken”? (more…)
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. | Matas Ideas and Thoughts