Not technically possible, I know. However, the situation I’m in is this:
I have nested for loops that create a 2-dimensional array of objects, like so:
for( i = 0; i < order.length; i++ ) {
for( j = 0; j < order[ 0 ].length; j++ ) {
tiles[ i ][ j ] = new Tile( order[ i ][ j ], findLinkageName( order[ i ][ j ] ), j * c_tile_width, i * c_tile_height );
}
}
I need to assign each of the objects an onRelease handler, so I stuck this line in right after the constructor’s called:
tiles[ i ][ j ].mc.onRelease = selectTile;
(Obviously, selectTile is defined earlier and mc is a property of the Tile class). The problem, as you may have guessed, is that the onRelease line fires before the constructor’s completed, so there’s no mc property to which a handler can be attached (mc is the MovieClip associated with the instance).
So my question is this: what’s the best way to delay that line until the constructor’s completed? I’d like to avoid having to create events and handlers just to add a handler; seems a bit like sending a tank after a gopher. Any thoughts?
The relevent files are attached. Let me know if I should clarify anything. Thanks.
Rys