there are a couple problems, and by this code, I'm not really sure what some of these are but:
1. Variables should not start with numbers (1._x) < - if a variable, is invalid
2. You have commas where I believe there should be decimals: 128,8, 218,5
3. Also, just for because I am picky, I would use whole numbers whenever possible, EXAMPLE: for 128.8, I would use just 128, or round up to 129.
4. use trace() to check and make sure you values are matching.
actually, now that I look back, I am seeing that the name is /1, I was seeing it as slash notation. It's just me, but I would refrain from using a special charachter as the begining in naming variables
1) drop1 (changed position to yx 0.0)
2) d1
3) congrats
d1 --> shall drop into drop 1.
This is the code now inside of both drop1 and d1:
on (press) {
startDrag("/d1");
}
on (press, release) {
if (_droptarget eq "/drop1") {
setProperty("/d1", _x, "0.0");
setProperty("/d1", _y, "0.0");
stopDrag();
}
}
on (release) {
stopDrag();
}
The drop function works. I tried to change it setProperty to:
movieClipName._x = 0.0;
movieClipName._y = 0.0;
But I didn't get it to work.
Code in rootframe: (for congrats movieclip to show when d1 is in the position 0.0)
congrats._visible = false;
I made a quick file for you. It is done in the most simplest form. all of the code is on the main timeline. Note: all items on the stage have an instance name that is reffered to in the actionscript.
I didn't think of this before, but your "if" statement will run as soon as you publish your file. that's why it doesn't work, because it is running before you even get the chance to drag and drop.
But the snapfunction doesn't seem to work. Because I want it to stop drag when you have put it in the right position. It doesn't do that now, although it seems like it should?
// set congratulation message
congrats_mc._visible = false;
//instance name of green circle
//This is what we want to drag.
// using "this" in front of drag
// is basically saying "drag "this"
// object which is the green ball.
obj_1_mc.onPress = function() {
this.startDrag();
}
//this code will check to see if the
//green ball was dropped in the target area
//drop_1_mc is the instance name of the target area
obj_1_mc.onRelease = rc_mc.onReleaseOutside=function () {
stopDrag();
if (this.hitTest(drop_1_mc)) {
stopDrag();
this._x = 602.0;
this._y = 317.0;
congrats_mc._visible = true;
}
}
there is no code that I know of that will allow you to drag, and it will automatically stop dragging, without you actually "dropping" the object (releasing the mouse button) If you put the stopdrag in the on press function - it will still drag until you release the button, but then strange things happen.