So what I would like to do is in each frame, after several frames have
elapsed, is to start fading the oldest line segment, then a couple of frames
later start fading the second-oldest, while continuing to further fade the
oldest, etc.
(...)
I tried the method of creating a new Shape every frame, just a line segment,
that I accumulate in an array.  That way I can fade them all separately
according to how old they are.  However the problem I had with this was that
the lines end up overlapping at a point, because I was doing the following.

In the end you'll never be able to use separate shapes. While you can change the caps of the lines, there's no easy way to avoid overlapping.

One easier solution is this: when you create each line, instead of creating a vector shape and adding it do a display object, you draw the line to a bitmap (create the shape, .draw it to the container bitmap, then remove the original line).

You'll need the bitmap to be added to a container. It works as a video buffer of sorts.

The trick is that after each line is drawn, you have to change the bitmap color accordingly, either by subtracting something from the alpha value of all pixels or by gradually filling it by another tinting. How you do this is up to you, there's a number of different ways to achieve the result (like adding the Bitmap to adisplayobjectcontainer, setting is alpha to 90%, .draw()ing it to a new bitmap, and replacing the old bitmap with the new one).

Also, depending on how you control the recoloring, you can chose to make it work like a relative fade (each line gets weaker and weaker but never disappears completely) or an absolute fade (each line disappears after X steps). It all depends on the kind of color/alpha transformation you apply to the buffer bitmap on every step.

You can also do some crazy tricks by using bitmap copies of every line and removing a shape with the mask of the new line from the old line, but that'd be harder than simply having a single bitmap copy which has gradual recoloring applied to it.

Zeh
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to