FORUMS: list search recent posts

Simple drag and drop help

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kristen Nellus
Simple drag and drop help
on Jan 6, 2010 at 2:35:57 pm

I am making a simple game of a snowman and his "parts". I have the parts on the right side of the screen. All I want to do is drag the items to the snowman and drop them. I have made the hat and converted the image to a movie clip(think that is right?). I then wen to the actions panel to find the global functions. I am being told that the movie clip is not able to have an action assigned to it. Not a clue what to try next. Any help? Thanks!

Return to posts index

Marcus Geduld
Re: Simple drag and drop help
on Jan 6, 2010 at 5:25:31 pm

You can't select a movieclip and then put code on it. Code can't go on movieclips. If you select a movieclip and then enter code in the Actions editor, you're telling Flash to make that code part of the movieclip, just as the clip's color is part of it.

Flash doesn't allow that. (It used to in an old version.) Code can only be placed on keyframes in the Timeline or in external text files that you link to the FLA.

You need to give the hat an instance name by selecting it and typing a name in the Properties Panel. (I'll assume you name it hat.) You the need to select the keyframe where the hat first appears (so that your code will go in that frame, not on the hat, bring up the Actions editor, and enter code that looks something like this:

(example file: )

var draggedClip : MovieClip;

hat.buttonMode = true;
//nose.buttonMode = true;
//leftEye.buttonMode = true;
//rightEye.buttonMode = true;
//pipe.buttonMode = true;

hat.addEventListener( MouseEvent.MOUSE_DOWN, mouseDownHandler );
//nose.addEventListener( MouseEvent.MOUSE_DOWN, mouseDownHandler );
//leftEye.addEventListener( MouseEvent.MOUSE_DOWN, mouseDownHandler );
//rightEye.addEventListener( MouseEvent.MOUSE_DOWN, mouseDownHandler );
//pipe.addEventListener( MouseEvent.MOUSE_DOWN, mouseDownHandler );

function mouseDownHandler( event : MouseEvent ) : void
draggedClip = as MovieClip;

draggedClip.removeEventListener( MouseEvent.MOUSE_DOWN, mouseDownHandler );
draggedClip.addEventListener( MouseEvent.MOUSE_UP, mouseUpHandler );
stage.addEventListener( Event.MOUSE_LEAVE, mouseUpHandler );


function mouseUpHandler( event : Event ) : void
draggedClip.addEventListener( MouseEvent.MOUSE_DOWN, mouseDownHandler );
draggedClip.removeEventListener( MouseEvent.MOUSE_UP, mouseUpHandler );
stage.removeEventListener( Event.MOUSE_LEAVE, mouseUpHandler );


Author "After Effects Expressions"
Co-author "After Effects For Flash, Flash For After Effects"
Artistic Director, Folding Chair Classical Theatre, Inc
Senior Flash Developer,

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved