I am a teacher and with the help of some of you, I managed to create very basic word game for kids where they are able to create words from letters. SWF | FLA
I have, however, been unable to continue to drag and drop the letters once they have been cloned from their originals on the side of the stage. Is anyone able to advise how I might be able to add this functionality to my existing code?
import flash.display.MovieClip;
for (var i=1; i<27; i++)
{
this["object" + i].addEventListener(MouseEvent.MOUSE_DOWN, onStart);
this["object" + i].addEventListener(MouseEvent.MOUSE_UP, onStop);
}
var sx = 0,sy = 0;
function onStart(e)
{
sx = e.currentTarget.x;
sy = e.currentTarget.y;
e.currentTarget.startDrag();
}
function onStop(e)
{
if (e.target.dropTarget != null &&
e.target.dropTarget.parent == dest)
{
var objectClass:Class =
getDefinitionByName(getQualifiedClassName(e.currentTarget)) as Class;
var copy:MovieClip = new objectClass();
this.addChild(copy);
copy.x = e.currentTarget.x;
copy.y = e.currentTarget.y;
}
e.currentTarget.x = sx;
e.currentTarget.y = sy;
e.currentTarget.stopDrag();
}
I would also love to include a 'bin' where kids can drag letters if they do not wish to have them on stage any more. Any ideas for how I could add this would be greatly appreciated.
Many thanks.