Time for action – transferring imageData
By setting the chosen image to be the same width and height as the group that holds the puzzle pieces (that's where the 900 and 662 numbers came from), it becomes possible to transfer the matching rectangle of data from the full image to the puzzle piece in question.
Open the card script again. Add the makepuzzle handler:
on makepuzzle resetpuzzle put the number of images in group "pieces" into imagecount repeat with a = 1 to imagecount makepiece the short name of image a of group "pieces" end repeat end makepuzzle
The makepuzzle handler will go through each of the puzzle pieces and call another handler to do the transfer of data for that piece. Here is the makepiece handler:
on makepiece piecename put the width of image piecename into piecewidth put the height of image piecename into pieceheight put empty into tempimage put the left of image piecename - the left of group "pieces"into dx put the top of image piecename...