Right. I've always been wary of the with construct (VB.NET, which I used
to work in, has it), but it can be used rather elegantly:
private function populateNode(d:DataSprite):Boolean
{
var p:Particle = d.props.particle;
if (p == null) {
d.props.particle = (p = _sim.addParticle(mass(d), d.x, d.y));
p.fixed = d.fixed;
} else {
with (p) { x = d.x; y = d.y; fixed = d.fixed; }
}
p.tag = _gen;
return true;
}
(from the flare[1] library)
[1] http://flare.prefuse.org
--
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com
-----Original Message-----
From: Troy Gilbert <[EMAIL PROTECTED]>
Reply-To: [email protected]
To: [email protected]
Subject: Re: [flexcoders] "With" statement in Pascal what is it in AS3
Date: Mon, 25 Feb 2008 11:49:55 -0600
> Is there a similar shortcut in AS3 to save my delicate fingers from
> excessive typing?
Yes, it's the "with" keyword... clever, huh? ;-)
Though, it's generally avoided because the scoping issues can be
unclear when reading the code.
Troy.