MovieCLip Instances & ActionScript Draggable MovieClips
LIFE – the off-brand version of Lifesavers Draw Something Create your object using the drawing tools LIFE – the off-brand version of Lifesavers They come in different colors, so I’m designing it in grayscale and will tint it later so I can have multiple varieties without having to redraw it
Convert it to a Graphic Symbol Select it Right-Click Convert to Symbol Name it
MovieClip
Create a MovieClip Can contain animations Can be assigned instance names Instance names can be used to apply ActionScript ActionScript is code that allows for interactions
Create a Movieclip Insert..New Symbol… Name it Make type: Movie Clip Naming this inner-life because I’m going to use some trickery to only have to code once by nesting inside another movie clip
See here that I’m inside the movie clip Drag in Graphic See here that I’m inside the movie clip Drag graphic life to stage from library
Make a second MovieClip Insert a new symbol Name it outer-life (this is outer movie clip for my trickery) Drag copy (an instance) of inner- move to the stage from the library
Name the instance Click once on the lifesaver Access the Properties Panel Assign it an instance name – mine in this example is “dragger” It must be one word, but that word is up to you Once it has a name we can control it with code
Open the Actions Panel Right-click on the first frame in the timeline (you should still be inside the outer movie clip Selection Actions Your code will go here
The Script //dragger=instance name //onPress = when mouse pressed //starts dragging the item that was pressed dragger.onPress = function () { startDrag(this); } //onRelease = when mouse released //stops dragging dragger.onRelease = function () { stopDrag();
Return to root (main) timeline Drag some instances of outer movieclip onto the stage Each instance automatically contains an already coded version of the inner movieclip When the move is tested, each individual movie clip will respond to dragging
Tinting the movie clips Select a movie clip Open the Properties Panel From Color Effect section, select Tint
How strongly to apply the color Tint Adjust sliders until desired color achieved preview How strongly to apply the color Amounts of RGB