Roadblock Ahead

Few more changes brings me closer to actual NeatTools behavior, and data flow.  When evoking a module’s engine() method, the module is now passed the incoming port number. Every module has three arrays:mom, kid, and connectionList. When a connection is created the arrays are updated. Both kid and mom are arrays of modules, connectionList is a list of outputs to inputs. A connection is made like this:

con1.drawConn (button1, led1, 0, 0);

which means draw a connection from button1 to led1 from output port 0 to input port 0 (I’m only using left and right ports for now). In the constructor for the connection, the arrays I mentioned are updated. So assuming there were no previous connections the result of the connection above would be:

button1.kid[0] == led1
led1.mom[0] == button1
//and
button1.connectList[0] == 0

So when you press button1, it envokes led1’s engine method like this:

for (var i:int = 0; i < kid.length;i++)
{
     kid[i].engine(connectList[i]);
}

And for now, that works. But it assumes a few things. First that the connectList length will match the total number of ports. If I connect something to 0 and 2, the code above will tell the first module that the connection came from port 0 and will fail to connect to the second module, because it will be trying kid[1] instead of kid[2]. I'll have to puzzle that one out.

Posted in AS3

Leave a Reply

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