3 Replies Latest reply on Nov 24, 2009 6:21 PM by kglad

    bring layer to front AND drag

    Angela Swift

      Hey guys, i've been receiving a ton of help here and love it but Im having a really bad time fixing this one part of an infographic im making.

      i need to do the following in a flash cs4/as2.0 file:

      1.) make all boxes draggable on the stage

      2.) on click/hover bring layer to the front.

       

      please check out my file. im just learning how to use array's and im almost there but still need a little help. thank you

       

      var city_arr:Array = new Array("THIS CONTAINS A LIST OF ALL MY CITIES I AM USING AS MY NAMING CONVENTION");
      
      //I GET CONFUSED ON THIS PART
      for (i=0;i<city_arr.length;i++){
           var citybox:String  = city_arr[i] + "_box";
           this[citybox]._visible = false;
           this[citybox].drag_mc.onMouseDown = function(){
                this._parent.startDrag();
           }
           this[citybox].drag_mc.onMouseUp = function(){
                this._parent.stopDrag();
           }
           this[citybox].close_btn.onRelease = function(){
                this._parent._visible = false;
           }
      }
      
      
        • 1. Re: bring layer to front AND drag
          kglad Adobe Community Professional & MVP

          don't use mousedown and mouseup events.  all your objects will respond to the mouse no matter the mouse's location.

           

          try:

           

           

           

          var city_arr:Array = new Array(THIS CONTAINS A LIST OF ALL MY CITIES I AM USING AS MY NAMING CONVENTION);

          //I GET CONFUSED ON THIS PART
          for (i=0;i<city_arr.length;i++){
               var citybox:String  = city_arr[i] + _box;
               this[citybox]._visible = false;
             this[citybox].drag_mc.onRollOver = function(){
                    this._parent.swapDepths(this._parent.getNextHighestDepth());
               }

               this[citybox].drag_mc.onPress = function(){
                    this._parent.startDrag();
               }
               this[citybox].drag_mc.onRelease = function(){
                    this._parent.stopDrag();
          }
               this[citybox].close_btn.onRelease = function(){
                    this._parent._visible = false;
               }
          }

          p.s.  i'm not sure you want to make all this not visible

          • 2. Re: bring layer to front AND drag
            Angela Swift Level 1

            that worked perfectly but now i need to figure out how to bring the box to the front on the first initial click of the house...when you click on new houses some pop-ups get lost behind others so i need to bring them to the front. can anyone help with that?

            • 3. Re: bring layer to front AND drag
              kglad Adobe Community Professional & MVP

              use the swapDepths() method of movieclips (as was done in your rollover).