Line Movement and Interaction in AS3

For quite some time now, I’ve been trying to figure out the best way to get lines to “move” in AS3. By this, I don’t mean simple rotation and skewing of an existing line, but actually changing the line structure: length, thickness, etc. The challenge first became noteworthy when I was working on my Tower Defense code, and I wanted to have a laser-esque tower that would shoot constantly at an enemy rather than launching projectiles. In other words, I wanted the origin point of my segment to be stationary while the other end of the segment follows the targeted creep. Based on some old Java graphics experience I have, my first thought was to re-render (literally create and destroy) the Sprite object housing the laser on a timer or Event.ENTER_FRAME. However, this immediately proved to be a poor decision, since it caused a horrible flicker, just like a Java applet that was animating without double buffering. So, needless to say, I needed to dig a little deeper into the core of the AS3 Graphics object.
Continue reading