Skip to navigation

New, Improved Flash ‘Fuzzy Felt’

Last year I wrote about how to create a drag-and-drop activity with simple ActionScript, and afterwards realised I should’ve added a couple more lines of code. Here’s an improved version that stops pieces getting dragged off the edge, and moves them to the front when they’re clicked.

To create a draggable piece, put a graphic/animation into a button, and put this script on the button:

on (press)
{
	startDrag(this,false,0,0,Stage.width,Stage.height);
	_parent.topDepth ++;
	this.swapDepths(_parent.topDepth);
}
on (release, releaseOutside)
{
	stopDrag();
}

Then put the button into a movie clip. Repeat for all pieces.

Here’s an updated example FLA (Flash MX or newer required).

Filed under: Client-side Coding, Games and Multimedia, Hints and Tips


Comments


Comments are now closed for this entry.

Malevolent Design Weblog

Matt Round’s company blog, covering web development, media, technology and pretty much anything else.

Blatant self-promotion

Web Sites
Good-looking, effective, accessible sites.
Multimedia
Logos, Flash games, animation and illustration.
Advice
Help with strategy, planning and getting noticed.