9 Replies Latest reply on Jun 18, 2009 7:39 PM by Ned Murphy

    Need a click and drag script for multiple layers.

    evergreen481

      Hi. I'm realitivly new to Flash and Action Script.

      For a Majour project school asignment i am trying to create an interactive map for a hypothetical theme park, and i'll cut to the chase, i need a script that allows the player to drag the content of two or three layers around the screen upon mouse click, similar to this example:\

       

      http://www.dreamworld.com.au/content/drw_2008_shopping.asp?name=ParkMap

       

      I will have a layer for buttons (probably called Buttons) and a layer for the map graphic (Probably called Map), similar to this tutorial:

       

      http://www.republicofcode.com/tutorials/flash/interactive_map/

       

      If anyone could produce, or has a script lying around that could do this; i would really apreciate it.

      This assignment has a large impact on my UAI (universities admission index).

       

      Thanks for your time,

      Pat

        • 1. Re: Need a click and drag script for multiple layers.
          Rothrock Level 5

          Umm, if it is for getting into Uni shouldn't you do your own work?

           

          Tutorials are a good place to start.

          • 2. Re: Need a click and drag script for multiple layers.
            evergreen481 Level 1

            Thanks for replying.

             

            It's an assignment for a subject called 'design and technology'. We can out source certain parts of our assignment, e.g. a girl in my class is designing a lounge but getting someone else to make it for her. Provided we tell the markers this is happening, it is not only allowed- but enouraged.

             

            So to answer your question asking someone for code help would not be ethically or ... err.... legally wrong.

             

            And yes, tutorials are a good place to start, if you read my first post you would find i am using them currently, but after countless hours could not find one that teaches you how to move multiple layers.

             

            But please, i still need help, and if anyone knows how to make this work i would greatly apprciate an answer.

            Even a link to an appropriate tutorial would be awesome.

             

            Thanks, Pat.

            • 3. Re: Need a click and drag script for multiple layers.
              Ned Murphy Adobe Community Professional & MVP

              To be like the first example site you showed, you would make a movieclip to house everything you want in the map.  It would include a background movieclip that you assign drag code for, but that drag code moves the _parent movieclip rather than the background alone.  Doing it this way, you can then add buttons and other movieclips on top of that background clip that would still be interactive (since they are on top of the background) and would mo9ve with the background since the _parent movieclip is what's being moved.

              1 person found this helpful
              • 4. Re: Need a click and drag script for multiple layers.
                evergreen481 Level 1

                Ok, i think i get what your saying.

                I'll try it out and get back to you.

                 

                Thanks.

                • 5. Re: Need a click and drag script for multiple layers.
                  evergreen481 Level 1

                  It almost worked;

                   

                  Can you give me an example of where to place the script? So far i have a mouse event script:

                   

                  on (press) {        startDrag (this, true);}
                  on (release) {        stopDrag ()}

                   

                  But this can't work as it can only be applied to a button, and this symbol is a Movie Clip.

                   

                  Thanks again.

                  • 6. Re: Need a click and drag script for multiple layers.
                    Ned Murphy Adobe Community Professional & MVP

                    for what you just showed, try this...

                     

                    on (press) { startDrag (this._parent, false);}

                     

                    Movieclips can have mouse-interactive code assigned for them.

                     

                    Here is an example file, hopefully saved as a Flash 8 file--the earliest I can save to with this machine.  It contains a movieclip, which would be the overall map, and inside is a background and a button.  The background has the drag code assigned to it to drag the _parent movieclip...

                     

                    http://www.nedwebs.com/Flash/dragMap.fla

                    1 person found this helpful
                    • 7. Re: Need a click and drag script for multiple layers.
                      evergreen481 Level 1

                      Thanks for your help. I really appreciate it.

                       

                      The problem is; this is the script i am using to make the map interactive:

                       

                      import mx.transitions.Tween;
                      import mx.transitions.easing.*;

                      var cities:Array = ["muscat", "sohar", "dubai","abu_dhabi"]


                      function mover (targetX, targetY){
                      currentX = marker_mc._x;
                      currentY = marker_mc._y;
                      var xTween:Tween = new Tween(marker_mc, "_x", Strong.easeOut, currentX, targetX, .5, true);
                      var yTween:Tween = new Tween(marker_mc, "_y", Back.easeOut, currentY, targetY, 1.5, true);
                      }

                      for (var i = 0; i<cities.length; i++){
                      var my_btn = this[cities[i]+"_btn"];
                      my_btn.myCity = cities[i];
                      my_btn.onRollOver = function() {
                      mover( this._x, this._y);
                      marker_mc.gotoAndStop(this.myCity);
                      }
                      }

                       

                      And when the buttons are made to be part of a movie clip with the image i am using for the background this script does not work.

                      The script is located in a layer called "Actions", if that is of any help at all.

                       

                      Any ideas?

                       

                      I am sorry if I am being a newsense.

                       

                      Thanks

                      • 8. Re: Need a click and drag script for multiple layers.
                        evergreen481 Level 1

                        Could some one please help?

                        • 9. Re: Need a click and drag script for multiple layers.
                          Ned Murphy Adobe Community Professional & MVP

                          Could you explain what you have done as far as creating the moveable map goes, and what you are trying to do with that code you showed.  Describe the pieces, how they fit together, where the code is relative to those pieces, and what that code is supposed to be doing.