
Create a Box Button. Again Convert this button to MovieClip.
Name the instance of the each MovieClip like source_mc
Create one more MovieClip in the Stage name the instance dest_mc
Select the button to write the actionscript by, RightClicking the source_mc MovieClip > 'Edit in place', select the button press F9.
Add the code:
- on (press, dragOver) {
- startDrag(this);
- //trace(this._name);
- }
- on (release, dragOut) {
- stopDrag();
- if (this.hitTest(_parent.dest_mc)) {
- trace("you hit the Destination");
- //trace(_parent.dest_mc._x);
- this._x = _parent.dest_mc._x;
- this._y = _parent.dest_mc._y;
- } //end-if
- }
Here we are moving the position of the source_mc MovieClip to dest_mc MovieClip when the Movieclip finishing the moving by using HitTest
Note: You can use _root or _parent that depends upon the place where we are using ,here using _parent.dest_mc.
No comments:
Post a Comment