Paul,
apologies however languages such as C# include such a directive
already - its not "reducing" readability at all - in reality I'm
wondering if this is remotely possible in Flex. The issue I'm
wondering about is that if you wrote the code below....
var object:Object = new Object();
With (object) {
x = 20;
trace("trap the app in debug here");
}
and placed a breakpoint on the trace line - you'll note several things
- 1) 'x' is defined as a variable of type Number (no var declaration
which I didn't think possible) and outside of the scope of 'object' 2)
object does not have a variable 'x'.
How is it shown that 'x' is part of 'object' rather than an external
variable ?
In C#, the With statement is enacted in that properties of a object
declared in the With construct are referenced in the following manner.
With (object) {
.x = 20;
}
Note the '.' !
Thanks & Regards
Samuel
On Nov 5, 2007, at 4:13 PM, Paul Decoursey wrote:
I think that with should be avoided, it greatly reduces the
readability of your code and makes maintaining it more difficult.
On Nov 5, 2007, at 8:53 AM, Brent Dearth wrote:
var o:Object = {a: 20, b: "twenty"};
trace (o.a + " " + o.b);
with (o) {
a = 40;
b = "forty";
}
trace (o.a + " " + o.b);
On 11/5/07, Samuel Colak <[EMAIL PROTECTED]> wrote:
Not quite what i mean - not to call the function but referring to
properties inside the object - your demo implies a static object
"Math" with functions cos and sin.
inside the "object" i have a getter and setter for the property "x".
Regards
Samuel
On Nov 5, 2007, at 10:56 AM, Edward Yakop wrote:
I'm not sure what u meant, but [with] statement does exists.
For example, taken from the flex doc:
<code>
var a:Number, x:Number, y:Number;
with (Math) {
a = PI * pow(r, 2);
x = r * cos(PI);
y = r * sin(PI / 2);
}
</code>
where pow, cos and sin are static method of Math.
Regards,
Edward Yakop
On Nov 5, 2007 10:45 AM, Samuel Colak <[EMAIL PROTECTED] >
wrote:
> Guys,
>
> am i going nuts and that there is no with construction for objects
> (such like....)
>
> object.x = 20 (x is a number)
>
> or
>
> WITH (object) {
> .x = 20
> }
>
> Just wondering....
>
> Samuel
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>