For this tutorial I made a draggable chicken but you can create whatever you wish. I will be showing you how to make the draggable object itself, not the chicken object.
Create a draggable object
Step 1
Create a new flash document.
Step 2
Create your movable object on the stage. I made a chicken but you can create whatever you wish.
Convert your object into symbol by selecting F8.
Give your symbol an appropriate name and check the movie clip button then click ok.
Step 3
Using the selection tool (v) select your movie clip and give it an instance name eg. chicken_mc.
Step 4
On the timeline, add a new layer called "actions" then select the first frame of the action layer and press F9. This opens up the actions window.
Add the following code:
chicken_mc.onPress = function () {
startDrag(this);
}
chicken_mc.onRelease = function () {
stopDrag();
}
**This piece of code is pretty self-explanatory when your draggable object is clicked by the mouse it starts the drag. And when it is released by the mouse it stops the drag.You should now a nice draggable object.





0 comments:
Post a Comment