Skip to navigation

malevolent design weblog

This blog is now defunct, but you can find more stuff over at my personal site

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).


Comments


Comments are now closed for this entry.