PDA

View Full Version : Drawing API syntax



chic0
August 10th, 2005, 02:22 PM
In Flash MX this code:


this.createEmptyMovieClip("someshapes", 1);
this.someshapes.lineStyle(2, 0x00ee00, 100);
this.someshapes.beginFill(0x00cc00, 50);
this.someshapes.moveTo(50, 50);
this.someshapes.lineTo(200, 150);
this.someshapes.lineTo(80, 210);
this.someshapes.endFill();
this.someshapes.lineStyle(3, 0x00eeee, 30);
this.someshapes.beginFill(0x0000cc, 60);
this.someshapes.moveTo(180, 130);
this.someshapes.curveTo(200, 80, 250, 70);
this.someshapes.curveTo(200, 10, 40, 90);
this.someshapes.endFill();
could also be written as:

this.createEmptyMovieClip("someshapes", 1);
with (this.someshapes) {
lineStyle(2, 0x00ee00, 100);
beginFill(0x00cc00, 50);
moveTo(50, 50);
lineTo(200, 150);
lineTo(80, 210);
endFill();
lineStyle(3, 0x00eeee, 30);
beginFill(0x0000cc, 60);
moveTo(180, 130);
curveTo(200, 80, 250, 70);
curveTo(200, 10, 40, 90);
endFill();
}

Could it be that in Flash MX 2004 that's no longer possible?
Cuz when I leave the 'this' behind, moveTo etc. don't color blue.. :(

Dauntless
August 10th, 2005, 02:46 PM
Actually I don't have experience with 'with', but I think it would be good if you would just don't use it again, since it's pretty old...

Oh, and I tested it -> I get two figures on my stage :) I guess the new syntax highlighter doesn't ligt the method up if you don't stage the instance on which it's invoked...

flashead
August 10th, 2005, 04:28 PM
apparently with() is really slow anyway (not that it would cause an issue in your case).

dot syntax is where it's at!

chic0
August 11th, 2005, 02:35 AM
Okay thanks guys :)

But I've always wondered, flashead, how can u see what's fast and what's slow in AS?!:h: :sigh:

Greetz

Krilnon
August 11th, 2005, 02:37 AM
If you set a property (like add 1 to it each tim) and then trace it as fast as you can, you could see which is faster. I don't know if that's the way the others determined this, however.