Flex Developers: Get 'with' it!

I just re-discovered a little-used statement in Flex that can save a lot of typing.

Let's say I've got a block of code which sets a bunch of values into my value Object:

customerVO.firstname = 'Fred';
customerVO.lastname = 'Flintstone';
customerVO.city = 'Bedrock';
customerVO.dog = 'Dino';

I can write the same code like this:

with( customerVO ) {
      firstname = 'Fred';
      lastname = 'Flintstone';
      city = 'Bedrock';
      dog = 'Dino';
}

You can use the with statement to say: 'Everything inside this block refers to the object I specified in the parentheses'. You can access both properties and methods of the defined object.

Cool, eh?

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
maliboo's Gravatar What about with autocomplete with "with"?
# Posted By maliboo | 5/29/07 3:43 PM
Flex programming's Gravatar hey

Really nice tips!

will try to keep it in my mind

thanks!
# Posted By Flex programming | 10/20/08 12:38 PM
BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.