web developer, flash maser, java newbie, gamers
Drag and drop is a very popular animation in flash. its commonly use to create a learning application where elements needs to be associated.
In this basic drag and drop tuturial i will expain the process to creat a drag and drop in flash8 actionscript2.0
1. creata a new flash document
2. create a new shape, use whatever you want.
3. convert this sape to a movie clip
4. set registration point to centre
5. give it instance name circle.
6. on the first frame of the timeline enter this actionscript :
circle.onPress=function(){
starDrag(this,true)
}
circle.onRelease=function(){
this.stopDrag();
}
actionscript explaination :
if circle is press start drag if it released stop dragging
this is startDrag documentation in flash8
startDrag function
startDrag(target:Object, [lock:Boolean, left:Number, top:Number, right:Number, bottom:Number])
Makes the target movie clip draggable while the movie plays. Only one movie clip can be dragged at a time. After a startDrag() operation is executed, the movie clip remains draggable until it is explicitly stopped by stopDrag() or until a startDrag() action for another movie clip is called.
Parameters
target:Object - The target path of the movie clip to drag.
lock:Boolean [optional] - A Boolean value specifying whether the draggable movie clip is locked to the center of the mouse position (true ) or locked to the point where the user first clicked the movie clip (false ).
left,top,right,bottom:Number [optional] - Values relative to the coordinates of the movie clip’s parent that specify a constraint rectangle for the movie clip.
source fla :
http://siubie.zxq.net/wordpress/wp-content/circle.fla
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jul | ||||||
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |