What am I not seeing?
I have dozens of movie clips on the stage and dozens more that are added dynamically. (Think a puzzle…bits on the stage and other pieces that are dynamically added and the shapes match and you have to drag the pieces that are added to the pieces that are already on the stage and they “lock” into place.)
I have over 100 puzzle pieces. They are identical except for shape. 98 of them work. 2 do not.
Here is the code:
if (this.dropTarget.parent is GeoPuzzle) {
if (GeoPuzzle(this.dropTarget.parent).abbrev == this.abbrev) {
PuzzleGlobals["unitsCompleted"+PuzzleGlobals.puzzleAbbrev]++;
GeoPuzzle(this.dropTarget.parent).isLocked = true;
*trace (this.dropTarget.parent);* //correct both times
GeoPuzzle(this.dropTarget.parent).gotoAndStop("Lock");*
trace (this.dropTarget.parent);* //null first time, correct second
}
}
For 98 of the pieces, this works perfectly fine. But for two of the pieces (class GeoPiece), the FIRST time I try to drop them on the their proper shape (class GeoPuzzle), the first trace line traces properly and the second trace line traces null. The SECOND time I try to drop them on their proper shape, both traces trace correctly.
And when I say “first time” and “second time” I mean I pick up the piece and move it over the drop spot and drop it. Wrong trace. I pick it back up and move it back over that spot. Right trace. Exactly like that. For just those two pieces. Every time.
What am I not thinking of?