Groups | Blog | Home
all groups > flash actionscript > may 2005 >

flash actionscript : What's with WITH?



Pat D.
5/20/2005 12:00:00 AM
This morning I decided to try a new tack on my issues with text not displaying
reliably in datagrids. I created a new cellrenderer and with some renaming
just had to recompile my flash file to use it. When I did I got all kinds of
odd behaviour. I quickly swapped back to my old version of the cellrenderer
but the odd behaviour continued. When I looked at the code it was apparent
that wherever I had used the "with (xxx) { }" construct it was ignoring the xxx
and applying all the steps to the local object.

Thing is I didn't download and apply any updaters. My cellrenderers do use
with but have never had a problem before. I'm soo confused.
SMakinson
5/20/2005 12:00:00 AM
Pat D.
5/24/2005 12:00:00 AM
What's odd is it worked fine for quite a while. I have a few already compiled
movies that used it; if I go in to make any mods I feel certain WITH will break
and I'll have unexplained bugs all over this thing.
Jeckyl
5/25/2005 12:00:00 AM
'with' doesn't break .. but you do have to understand it to use it properly.
--
Jeckyl

Pat D.
5/27/2005 12:00:00 AM
I thought this:

this.sought_txt.border = true;
this.sought_txt.background = true;
this.sought_txt.backgroundColor = 0xE2E9EE;
this.sought_txt.html = true;
this.sought_txt.multiline = true;
this.sought_txt.wordWrap = true;

...and this:

with (this.sought_txt) {
border = true;
background = true;
backgroundColor = 0xE2E9EE;
html = true;
multiline = true;
wordWrap = true;
}

were functionally identical. Am I wrong? It sure worked this way for a while
before it decided to stop working this way somehow.

LuigiL
5/27/2005 12:00:00 AM
Jeckyl
5/27/2005 12:00:00 AM
[quoted text, click to view]

Sometimes. It will only work if (in this case), 'border' is already a
property of the this.sought_txt, and if this.sought_txt already exists.

You cannot set new properties using a 'with' .. only access or change
existing properties.

Jeckyl

Pat D.
5/27/2005 12:00:00 AM
Jeckyl,

That may well be what it was. I had been condensing some code and perhaps I
had removed some earlier references setting things because I realized I was
doing it within the WITH block.

Thanks!
Pat D.
5/27/2005 12:00:00 AM
Somewhat related to this topic is this one.

I tried creating an initialization object for some things. Setting it up as
{_x:10,_y:20} worked fine so I got braver and tossed a whole bunch of things in
there similarly. I seem to remember that it complained at some point and I
took most of it back out.
AddThis Social Bookmark Button