Groups | Blog | Home
all groups > flash actionscript > december 2006 >

flash actionscript : Dotted Lines as outline for dynamically created shapes?


nickadtrain
12/20/2006 8:32:39 PM
Hey all, I'm building a site whose flat, vector shapes need an outline of a
dotted line.

The majority of these shapes are simply rectangles with rounded corners. All
are created dynamically.

I could do each shape's lines by hand and attach them, but I'd much rather use
a script. Anyone have any suggestions? :) I could use a good jump-start on
tackling this.

Thanks in advance -
andy
Hex
12/20/2006 9:10:49 PM
I just copy and paste from flash 8 help ... Think this curveTo method
will help you to outlining images....

HeX


this.createEmptyMovieClip("circle_mc", 1);
with (circle_mc) {
lineStyle(0, 0x0000FF, 100);
beginFill(0xFF0000);
moveTo(0, 100);
curveTo(0,200,100,200);
curveTo(200,200,200,100);
curveTo(200,0,100,0);
curveTo(0,0,0,100);
endFill();
}



[quoted text, click to view]
kglad
12/21/2006 12:00:00 AM
if you're attaching rectangles created in the authoring environment, create
them with a dotted border. if you're creating your rectangles with the drawing
api (with rounded corners), i don't see an easy way to draw dotted rounded
corners.
myIP
12/21/2006 12:00:00 AM
Yeah I agree, this is not an easy task. However senocular has a package that
you can download that will get you pretty close to your goal. So if you
download the zip here;

http://www.senocular.com/flash/source.php?id=0.159

?and comment out and modify the code in the fla as the following;

import com.senocular.drawing.*;

// create ProgressiveDrawing instance to draw in _root
//var myDrawing:ProgressiveDrawing = new ProgressiveDrawing(_root);

// create DashedLine instance to draw in myDrawing (ProgressiveDrawing)
// use random dash sizes
var myDash:DashedLine = new DashedLine(this, 35, 35);

// reset linestyle to random size and color
myDash.clear();
myDash.lineStyle(5, 0xFF0000, 100);

// draw a circle in the myDash instance
circle(myDash, 150,150, 200,200, true);

// because all myDash drawings were added to myDrawing,
// myDrawing will draw a dashed circle when draw is called
//myDrawing.draw(100);

?this will create a constant circle with a dashed line versus creating a
random circle. You can obviously change the values on that frame which will
change the color and spacing between the dashes (and a few other parameters
will change others). If you notice the circle(), this is created also on the
first frame but on a different layer. This is where you would want to change
your shapes. Just create another layer that will contain a different shape. I
hope this helps, regardless have a high regard for senocular and other
developers that contributed to this package.

AddThis Social Bookmark Button