mandingo: I won't ask what your other hand is clutching :):):):):)
BTW: the code from NSurveyor ...
[quoted text, click to view] >>>
btn_1.onRelease = function(){
clip3._visible = (clip1._visible = !clip1._visible) && clip2._visible;
}
btn_2.onRelease = function(){
clip3._visible = (clip2._visible = !clip2._visible) && clip1._visible;
}
[quoted text, click to view] >>>
.... is indeed shorter and "clever", BUT it is more complicated and not as
good overall. Assignment statements within an expression are VERY VERY bad
style.
The reason .. when you (or someone else) comes back later to maintain this
code, you'll see the line:
clip3._visible = (clip2._visible = !clip2._visible) && clip1._visible;
and immediately think: "Damn .. who wrote this, they should know you need an
== instead of an =" and "fix" the line to be:
clip3._visible = (clip2._visible == !clip2._visible) && clip1._visible;
and then sometime later, you'll look at it again and say "That's dumb .. how
can visible and not-visible ever be equal .. that's always going to be
false" and "fix" the line to be:
clip3._visible = false && clip1._visible;
and then immediately realise the doing an && with false will ALWASY give you
false, and so it gets optimised down to:
clip3._visible = false;
It is best to keep assignments as separate statements .. not ever put them
in the middle of an expression where they looks 'wrong' .. even if it may be
'clever' and concise to do so.
Long code can be complicated, short code can be complicated .. in between
there is an optimum simplicity and clarity. Concise enough not to be
overwhelming, and verbose enough to be easily understood and unambiguous.
Finding that balance is part of the art of programming.
--
Jeckyl