First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Jesse

Step 2: Re-drawing the user's art

Now go to the sixth frame of the root timeline, insert a keyframe and remove the ok movie clip. Paste the following code into the actions panel.

pen.lineStyle(1, 000000, 100)
pen.moveTo(lines.line1[0], lines.line1[1])
_root.onEnterFrame = function(){
	line += 1
	name = "line"+line
		pen.moveTo(lines[name][1], lines[name][2])
		line += 1
		name = "line"+line
		pen.lineTo(lines[name][0], lines[name][1])
_root.onMouseDown = null
_root.onMouseMove = null

This code is kind of complicated. First it clears all the drawings in the pen movie clip, and sets up it's line style. Then, it moves to the first position. Then, every frame, the line variable adds one, and we set the name variable to "line"+line(so if line is 3 then name is line3.) Then, if the current thing to do is break, then the pen moves to the new position, adds one to the line variable, and sets name to "line"+line(again) This way, instead of having a pause in the drawing, it moves to the new position and draws a new line at the same time. Finally, if not all the lines have been drawn, we draw a line to the current position. Export the movie and make a drawing. Then click OK. The game will draw your drawing for you! It does it pretty slow, though. Increase the frame rate. This will make the lines draw faster. That's it! You've just made a fun game. You can also make a different impression of the art by adding things like 5 or 10 to the lines variable. This will let the computer make the art more robotic. But don't add more than one if there's a break in the drawing! Then the drawing will start at different points instead of just going to points faster. Export different versions of the swf. Try changing the lineStyle for each frame. Try making the computer make a random version of the art! This will be easy to do. Simply type in the following code instead of lines += 1

lines += random(5)+1

Try lots of variations and even send them to me if you really like them.

» Level Intermediate

Added: 2004-12-24
Rating: 8 Votes: 7
(10 being the highest)
» Author
Just started working with Flash.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.