Confusing linestyle problem. Linestyle applying backwards?[SOLVED:end your fills]

6 posts

Flag Post
sprite.graphics.lineStyle(1, 0xD8D8D8, .3);
while (i < 14) {
				sprite.graphics.moveTo( -14, -14 + (i * 2));
				sprite.graphics.lineTo(14, -14 + (i * 2));
				i += 1;
			}	
			i = 0;
			sprite.graphics.lineStyle();//added to attempt a fix
			sprite.graphics.lineStyle(3,0xD8D8D8);
                        sprite.graphics.moveTo(-8,0);
///then goes on to draw more lines

The last line that’s drawn in the loop is drawn with the (3,0xD8D8D8); linestyle…even if I comment out all the drawing commands after setting the new linestyle, including the last line I’ve shown here…..

It seems that when I change the linestyle, it applies retroactively, to the previous .lineTo

 
Flag Post

I can’t reproduce the issue. I suspect that the problem lies in some code that you didn’t post, either before or after this snippet.

I suppose there’s also a chance it’s related to that misspelling on the last line.

 
Flag Post

Nah, that’s just a typo. I’ve commented out every station.graphics line in the whole thing except these: and it’s still happening

station.graphics.beginFill(colour);
			station.graphics.drawRoundRect( -15, -15, 30, 30, 7, 7);
			station.graphics.lineStyle(1, 0xD8D8D8, .3);
			while (ratarspd < 15) {
				station.graphics.moveTo( -14, -14 + (ratarspd * 2));
				station.graphics.lineTo(14, -14 + (ratarspd * 2));
				ratarspd += 1;
			}	
			ratarspd = 0;
			while (ratarspd < 15) {
				station.graphics.moveTo( -14 + (ratarspd * 2), -14);
				station.graphics.lineTo( -14 + (ratarspd * 2), 14);
				ratarspd += 1;
			}	
			ratarspd = 0;
			station.graphics.lineStyle();
			station.graphics.lineStyle(3,0xD8D8D8);

station is a sprite, colour is a uint, ratarspd is an int, it’s for something else but I’ve commandeered it temporarily for this loop…..it isn’t doing anything else while this is happening I’m sure.

 
Flag Post
while (ratarspd < 10) {
				station.graphics.lineStyle(1, 0xD8D8D8, .3);
				station.graphics.moveTo( -14 + (ratarspd * 2), -14);
				station.graphics.lineStyle(1, 0xD8D8D8, .3);
				station.graphics.lineTo( -14 + (ratarspd * 2), 14);
				ratarspd += 1;
			}	
			ratarspd = 0;
			station.graphics.lineStyle(1, 0xD8D8D8, .3);
			station.graphics.lineStyle();
			station.graphics.lineStyle(1, 0xD8D8D8, .3);
			station.graphics.lineStyle(3,0xD8D8D8);

And STILL the last line in the loop is drawn with (3,0xD8D8D8);, but fuck knows why. I suppose it must be something somewhere else in the code, but I have no idea where to look.

 
Flag Post

I remember having a situation where I left out a graphics.endFill after graphics.beginFill and it caused problems similar to how this sounds. Perhaps check to make sure you endFill after any beginFill? Other than that i’m not sure what the problem would be.

 
Flag Post

Yes! That was it, ta muchly. Serves me right for ignoring good practice…