Search Tutorials
Dragable Masks in Flash 5Adding the ScriptWhile still in the edit mode for 'dragMovieClip', right-click on the button and select actions. (You can also select the button and choose the actions panel from the menu.) Add the following code:on (press) {
startDrag ("");
}
on (release) {
stopDrag ();
}
You can define the drag area to the size of the background image as well, which I would recommend.
Now exit the movie clip edit mode and return to the main stage. Select 'dragMovieClip', set and give it the matching name in the Instance panel, 'dragMovieClip'. Right-click on the clip and select actions. Add the following code: onClipEvent (enterFrame) {
setProperty (this.bgImage, _x, -this._x);
setProperty (this.bgImage, _y, -this._y);
}
This tells 'bgImage' to reset its position based on the position of 'dragMovieClip' on the stage. If 'dragMovieClip' is at 100, then 'bgImage' moves to -100 to offset the movement and give the appearance of the the bacground image staying still.
At this point you are done. Publish the movie and see your work. If there are problems, first check to see that you gave 'bgImage' and 'dragMovieClip' and instance name. If the movement is off, make sure the image in 'bgImage' is aligned to 0,0 and that it's original position is where you want it on the main stage. Finally, check to see that the action on your movie clip is set to 'onMouseEvent(enterFrame)' instead of the default 'onMouseEvent(Load)'. If you are still having problem go back through and double check all of your step. If you're really stuck you can email me at tutorials@jcsaviorproductions.com. | |||||||||||||