Flash lets the user draw pictures by scaling, and then attaching a line clip. (I have included a tutorial swf about the line engine because the concept is important and warrants a separate discussion. Flash MX obsoletes the technique, but it can't hurt to understand it.) A record function on the main timeline uses clipEvents in a Controller Clip to load the mouse's position into two arrays. Two more arrays are used to hold the distances between X and Y coordinates. Once the user is finished drawing, another function redraws the picture by retrieving the coordinates from the populated arrays. Because the functions and arrays are all located on the main timeline (frame 1), the user can replay and redraw as long as s/he wants to. This file marks a shift in my ActionScripting. I am learning to keep scripts in one place. Some of my previous files were a bit messy (Optic Infusion Slideshow is the worst). I have discovered that there are many advantages to structuring scripts in this manner. BTW, there aren't a lot of fancy graphics because I wanted to see how small I could get this file. The star background is not discussed. Just pick a star and peek at its clipevents. It's fairly straightforward.
|» Level Intermediate|
Rating: 6 Votes: 46
|I'm a country without borders--a king without a castle.|
|Download the files used in this tutorial.|
|Download (30 kb)|
|More help? Search our boards for quick answers!|