Note that there are some explanatory texts on larger screens.

plurals
  1. PODrag and Drop error 1010 part of the time?
    text
    copied!<p>I have a working drag and drop game, but it's not perfect. All my movieclips drag and drop to their targets when you are exactly lined up with the target. </p> <p>However, if you let go of the mouse up when dragging the mc outside of the target zones, it will sometimes, but not always, throw the 1010 term undefined error and will not snap the mc back to its original start x/y coordinates (it just leaves the mc in the spot it was during mouse up). I ran the debugger and it deals with this line in my drop function:</p> <p>if (event.currentTarget.dropTarget != null &amp;&amp; MovieClip(event.currentTarget.dropTarget.parent).allowed.indexOf(event.currentTarget) >= 0){</p> <p>FYI, allowed is a set of target arrays since I wanted "zones" for targets and not specific targets for some of the movieclips.</p> <p>Any ideas?</p> <hr> <p>Updated Code Below:</p> <pre><code>if (event.currentTarget.dropTarget != null) { var mc:MovieClip=event.currentTarget.dropTarget as MovieClip; if (mc==null) { // typecast fails. Say there's a Sprite below reply_txt.textColor = 0xEE1212 reply_txt.text = "Oops! Try Again!"; event.currentTarget.alpha = 1; event.currentTarget.x = startX; event.currentTarget.y = startY; return; // nothing to do here } mc=mc.parent; if (mc &amp;&amp; mc.allowed) { // this MC has "allowed" property not "undefined" - we're in the grid // so now we can check indexOf() safely if (mc.allowed.indexOf(event.currentTarget)&gt;=0){ reply_txt.textColor = 0x33BC10 reply_txt.text = "Good Job!"; event.currentTarget.alpha = 1; event.currentTarget.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp); event.currentTarget.removeEventListener(MouseEvent.MOUSE_UP, dropIt); event.currentTarget.buttonMode = false; event.currentTarget.x = MovieClip(event.currentTarget.dropTarget.parent).x; event.currentTarget.y = MovieClip(event.currentTarget.dropTarget.parent).y; stored.push(event.currentTarget); startXarray.push(startX); startYarray.push(startY); counter++; } } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload