Hi Wazzap.
This Drag and Drop effect your refering to can be done by using the eval and _droptarget functions. Here is an example of what I think you want to create:
VIEW EXAMPLE
OK so I guess I’ll walk you through it.
On your main timeline create these layers
Actions
Button 1
Button 2
Button 3
Hole Mc
Now place a
stop; action on the 1st frame of the actions layer
Now create a new MovieClip and place a shape of your choice inside it.
Note: The shape you create will be the shape of the button
Give it an instance name of
mc_btn1
Repeat this step for your other 2 buttons and give the MovieClips an instance name of.
mc_btn2
mc_btn3
Now just use a bit of common sense and place the clips on their Layers.
Create a MovieClip and place your hole graphic inside it. Give that clip and instance name of hole_mc and place it on its Layer
Ok so your sage is setup, now for the ActionScript.
Actions for > mc_btn1
onClipEvent (load) {
this.onPress = function() {
this.startDrag();
}
this.onRelease = function() {
this.stopDrag();
if (eval(this._droptarget) == _root.hole_mc) {
this._visible = false;
_root.gotoAndStop("animation1");
} else {
this._visible = true;
}
};
}
Actions for > mc_btn2
onClipEvent (load) {
this.onPress = function() {
this.startDrag();
}
this.onRelease = function() {
this.stopDrag();
if (eval(this._droptarget) == _root.hole_mc) {
this._visible = false;
_root.gotoAndStop("animation2");
} else {
this._visible = true;
}
};
}
Actions for > mc_btn3
onClipEvent (load) {
this.onPress = function() {
this.startDrag();
}
this.onRelease = function() {
this.stopDrag();
if (eval(this._droptarget) == _root.hole_mc) {
this._visible = false;
_root.gotoAndStop("animation3");
} else {
this._visible = true;
}
};
}
Note: You will need to specify what frame should be stopped at once the button has been dropped in the hole by changing the code:
_root.gotoAndStop("animation1");
_root.gotoAndStop("animation2");
_root.gotoAndStop("animation3");
to either
_root.gotoAndStop("yourFrameName"); or
_root.gotoAndStop(2); // A frame ‘2’ on the main timeline
That’s it! Test ya movie and hopefully it works.
If ya have trouble heres an example source I whipped up. Nothing special but it does what you need!
Source Files
FlawedKid
Edited by FlawedKid, 04 April 2006 - 02:20 PM.