Victory is Mine. Sort of.

The reason I had to disable the dragging in the last one, was to get the children of a module (the ones it’s plugged into), I put a function call in the drawConnection function that collects the modules you’re passing it to connect.  So, for instance, when you create a connection between box1 and box2, this function says ok box1 has the child box2.  If you connect box1 and box3, it say ok box 3 is also a child of box1.  The function is a method of the Module class. The function looks like this:

public function addKid(m:Module):void
{
	var max:int = kid.length;
	kid[max] = m;
}

The problem with putting it in the draw connection method is that that method is called every frame to redraw the connection, so every frame, it re-adds the same children to the parent module, making the array.length much much longer than it should be and consequently producing some unpredictable behavior. My solution was to create two methods one that draws the connection initially and one that redraws it. They are identical save the one line that calls the function above. This is obviously not ideal, but it works. Switches next…

This movie requires Flash Player 9

Posted in AS3

Leave a Reply

Your email address will not be published. Required fields are marked *