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: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.