Drag and drop

I am boggled. This looks right to me but it won’t drag and drop. I would like to drage the mc “medium” over the mc “box”. If it is over it on release then lock to the center. Otherwise, go back to its original position. Any suggestions are appreciated.\r\ron (press) {\r&nbsp &nbsp &nbsp &nbsp startDrag ("_root.medium", true);\r}\ron (release) {\r&nbsp &nbsp &nbsp &nbsp stopDrag ();\r&nbsp &nbsp &nbsp &nbsp if (_root.medium._droptarget = _root.box) {\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _root.medium._y = “129.3”);\r&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp _root.medium._x = “350.3”);\r&nbsp &nbsp &nbsp &nbsp } else {\r _root.medium._x = “170.4.”;\r _root.medium._y = “75.9”;\r&nbsp &nbsp &nbsp &nbsp }\r}

I’ve had a few problems with getting drag and drop functionality to do exactly what I want, as it seems no two tutorials can quite agree on the best way to do it. I realise there’s no _root 's in there whatsoever. But whenever I put them in, the thing wouldn’t drag. However, this way seems to work OK for me:\r\ron (press) \r{\r startDrag ("");\r}\ron (release) \r{\r stopDrag ();\r if (medium._droptarget == “/box”) \r {\r medium._y = “129.3”);\r medium._x = “350.3”);\r }\r else \r {\r medium._x = “170.4.”;\r medium._y = “75.9”;\r }\r}\r\rOf course I could have got it totally wrong, but it’s worth a try.


 on (press) {\r\r        startDrag ("_root.medium", true);\r\r}\r\ron (release) {\r\r        stopDrag ();\r\r        if (_root.medium._droptarget = _root.box) {\r\r                _root.medium._y = 129.3;\r\r                _root.medium._x = 350.3;\r\r        } else {\r\r                _root.medium._x = 170.4;\r\r                _root.medium._y = 75.9;\r\r        }\r\r}

maybe ? I just removed the “” and the ).\rIt’s kinda strange though.\r\rpom 0]

well… please forgive me if Im over-simplifying but, it is worth asking.\r\ra few things:\r\r1.) your code is on a button that is inside a movie clip. Right?\r\r\r2.) _droptarget returns values in the form /objectname\ryou have to use eval in order to get dot syntax.\r\r3.) Im assuming you named your instances “box” and “medium”\r\rso… you can say:\r\rif (_root.medium._droptarget == “/box”) //notice the == in your code, you used a single =. Also, notice the quotes when using /box format. And finally, notice use of eval in order to change the expression from /box to _root.box.\r\ror you can say:\r\rif (eval(_root.medium._droptarget)) == _root.box) //notice again double == and lack of quotes when using dot syntax\r\rbut I dont think that\r\rif (_root.medium._droptarget = _root.box)\r\rwould work. However, I am certainly nowhere near the flash deities on this site (Supra, Upu, Ilia, eyez, etc…). Maybe one day.\rAfter looking at the code you submitted, there were several problems. I have attached working code. Hope this helps.\r\rThis works:\r\ron (press) {\r startDrag (root.medium, true);\r}\ron (release) {\r stopDrag ();\r _ _ _ _ _ _ _ trace(_root.medium._droptarget);\r if (_root.medium.droptarget == “/box”) {\r _ _ _ _ _ _ _ _ _ _ _ \r _root.medium._y = 129.3;\r _root.medium.x = 350.3;\r } \r _ _ _ _ _ _ _ else {\r_root.medium._x = 10;\r_root.medium._y = 10;\r }\r} \r\r\rPlease notice the following:\r\rIn your code you used the = sign. You really need to use == if you’re trying to get your if statement to compare.\r\rAlso you used “” and ( incorrectly… for example, here are some excerpts of your code…\r\r\r_root.medium._y = “129.3”);\r _root.medium._x = “350.3”);\r\rthe “” and the ) need to go in order for your code to work.\r\r\r\r"My name is Inigo Montoya. You killed my father. Prepare to die!"