Alignment for script readability
Something that really annoys me about ActionScript is the way it aligns the scripts. Take this example from the 'Survey' movie above. This is the way Flash writes it.
on (release) {
if (result == "") {
with (choices) {
gotoAndPlay(6);
}
theVote = "No selection!";
} else {
theVote = "You chose "+result+"!";
getURL ("mailto:you@youremailaddress? subject=survey: "+result,
"", "POST");
}
}
I much prefer this:-
on (release)
{
if (result == "")
{
with (choices)
{
gotoAndPlay(6);
}
theVote = "No selection!";
}
else
{
theVote = "You chose "+result+"!";
getURL ("mailto:you@youremailaddress? subject=survey: "+result,
"", "POST");
}
}
By aligning opening and closing curly brackets vertically - I've colour-coded them here for clarity - the whole thing becomes much easier to read, understand and debug. The more complicated the script, the more essential it is to present it in a logical, hierarchical fashion. The same goes for JavaScript!
Unfortunately, you have to go into Flash's 'expert' mode to achieve this kind of layout, and if you go back into 'normal' mode, it reverts to its original scrambled mess.
Send your TopTip to toptip@wpdfd.com

Del.icio.us
Digg
Technorati
Blinklist
Furl
reddit
Design Float