2 Replies Latest reply on Aug 29, 2013 3:29 AM by Kid_Icarus

    Drag & Drop Issue (locking to target object)

    Kid_Icarus Level 1



      I've been working with an interactive game and I've set up my objects (to drag) in one layer with their object targets in another. Export settings Flash 8 AS2 (requirement for the site it's being uploaded to).


      My objects have to snap back to their original position if they don't land on their target, and I have that working. What I can't get to work is for the object to snap into the box I've created.


      Both the object and the target have been converted to movie clips and the taget has been given an instance name (targetone) I've used that instance name in the action script that's been put on the object. Both target and object have their anchor points centred for X,Y purposes.


      Here is my actionscript:


      on (press)





      on (release)





      if(this._droptarget =="/targetone")








      this._x = 319.95;

      this._y = 138.75;






      It just won't snap into the box. The object is text converted to paths (large text) and the box is also large. I tried increasing it as I thought it may be having issues with locking in but to no avail


      Any help would be greatly appreciated!



        • 1. Re: Drag & Drop Issue (locking to target object)
          Ned Murphy Adobe Community Professional & MVP

          First use a trace to make sure that the target you are hitting agrees with the target you are indicating: "/targetone"


          I don't recall ever seeing something targeted using the syntax you show....  _/targetone


          Try using _root.targetone or _level0.targetone instead and see if that helps.

          • 2. Re: Drag & Drop Issue (locking to target object)
            Kid_Icarus Level 1

            Thanks for the reply, Ned.


            After a few hours of testing different script code, including your suggestions, I tried drawing an object directly onto the stage and it worked.


            I'm using boxes that are .ai files and they have been imported to the library with all of their layers and effects intact (as seperate components). I've discovered that the boxes I designed in Illustrator are too complicated to assign code to - I'm guessing it's because it has layers.


            I've got round it by drawing a simple box in Flash, positioning it over the illustrator versions and making it invisible. Problem solved!


            Case closed