Tutorial: Jigsaw using ActionScript 3.0.
Tutorial: Jigsaw using ActionScript 3.0.
Tutorial: Jigsaw using ActionScript 3.0.
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Now the challenge is to find a place to set up (register) the timing events. I decided to do<br />
it in the same function used to get the text field address 'over' to where the Piece class<br />
instances could use id. The new function to accomplish the task for setting up the text<br />
field to be used to display All Done and register the timing events is:<br />
public static function setups(t:TextField) {<br />
Piece.res = t;<br />
shorttimer.addEventListener(TimerEvent.TIMER,Piece.idler);<br />
longtimer.addEventListener(TimerEvent.TIMER,Piece.idler);<br />
}<br />
I added the following two statements to each of the startdragging, buildit and<br />
mixup functions.<br />
shorttimer.stop();<br />
longtimer.stop();<br />
There apparently is no harm in stopping a timer that is not started. This greatly simplifies<br />
the coding. It is possible to access the status of a timer, but it is not necessary here.<br />
The stopdragging function is the one to start the longtimer. Add this one<br />
statement:<br />
longtimer.start();<br />
This one requires patience to test! Be sure both files are saved (and that the .fla file has<br />
import jigsawidler.*;<br />
and the Piece.js file starts with<br />
package jigsawidler {<br />
<strong>ActionScript</strong> 2.0 to <strong>ActionScript</strong> 3.0<br />
Only read this if you are familiar with previous versions of Flash and want to reflect on<br />
the differences.<br />
As I say in all these tutorials, consider that much is the same: you still need to work with<br />
the base image and write down coordinates to be used for the offsetx and offsety<br />
values. What is different is how this information is associated with the piece. You need to<br />
set up buttons, and you need to set up events and write code for event handling for mouse<br />
actions and for key presses. Second, please appreciate the fact that creating the separate<br />
Piece files in the jigsaw and jigsawauto folders means that you can produce new<br />
jigsaw puzzles quickly. You do not copy code but use the very same files.