5 Replies Latest reply on Aug 11, 2014 2:49 PM by Ned Murphy

    Drag and drop to open link

    revilo

      Hi , I'm learning flash and have just upgraded from MX to CS5 . In MX I created a drag and drop actionscript that works fine , but now I want to modify it. In the original , an image representing an audio file could be dragged and dropped , and if it was double-clicked it opened that specific audio file and played the audio . I would like to get rid of the double-click and have the audio file open if the image is dropped on top of another image (of a record player) . Is it possible to activate the specific link for the audio file image by dropping it inside a box , or onto a button?

      Also , the MX version works fine , but do I have to rewrite it using Actionscript 3 , if I add further code in CS5?

      Thanks

        • 1. Re: Drag and drop to open link
          Ned Murphy Adobe Community Professional & MVP

          You can stick with AS2 coding even if you use CS5.  Just make sure your Publish Settings are set for AS2.

           

          As far as pursuing changes to the file go, you should  be posting in the AS2 forum.  I am going to move your posting there.  You should post the code you already have for the double-clicking interaction if you wish to have it changed to executing on a drop.  Showing it will help others to help you.

          1 person found this helpful
          • 2. Re: Drag and drop to open link
            revilo Level 1

            Thanks for the reply Ned.

            Here is the code

             

            //On press

            on (press) {

              this.startDrag();

            }

            //On release

            on (release) {

              this.stopDrag();

            }

            //On rollOver

            on (rollOver) {

              this.swapDepths(1000);

            }

            on(release) {

              var v0 = getTimer();

              lastclick = getTimer();

              if (lastclick - v0 + 500 > 0) {

              getURL("katie.html");

              trace("double");

              } else {

              trace("single");

              }

            }

             

            It shows a pile of "albums" to sort through and click through to the music. See http://www.olimalarky.co.uk/flash/musics.html

             

            I want to drag the image onto the image of a record player and have it open the link without clicking.

            Thanks for any help.

            Oli

            • 3. Re: Drag and drop to open link
              Ned Murphy Adobe Community Professional & MVP

              For the code that you show, you can get rid of the last "on(release)..." section and just use the first with the stopDrag line in it, changing it to something like the following, where the ??? will identify the record player...  use the trace above to determine what replaces ??? (then get rid of the trace)

               

              on (release) {

                   this.stopDrag();

                   trace(this.dropTarget);

                   if (this.dropTarget == ???) {

                        getURL("katie.html");

                   }

              }

              1 person found this helpful
              • 4. Re: Drag and drop to open link
                revilo Level 1

                Thanks a lot Ned.

                Oli

                 

                 

                On Mon, Aug 11, 2014 at 8:51 PM, Ned Murphy <forums_noreply@adobe.com>

                • 5. Re: Drag and drop to open link
                  Ned Murphy Adobe Community Professional & MVP

                  You're welcome Oli