3 Replies Latest reply on Mar 2, 2012 1:22 PM by kglad

    drag and drop to grid AS2

    anthony42589

      i want to create a grid where i can drag and drop items to it n save them, should i draw the grid myself and make a bunch of holders (as if i were making an inventory?) or is there a code i can use.

      i am pretty good with as2 but i never took the time to really get into arrays. i come up with my own solutions, but i want to make this the right way.

       

      for ex.sims build mode. 

       

      anyone interested in helping me out with my game also?  Doesnt hurt to ask.

        • 1. Re: drag and drop to grid AS2
          kglad Adobe Community Professional & MVP

          among the ways to do this, create a movieclip that will be one cell of your grid.  you can then layout your grid (using attachMovie) using a double (row/column) for-loop and assigning each cell an appropriate name property.

          • 2. Re: drag and drop to grid AS2
            anthony42589 Level 1

            ok so when i click the square(with the item selected) how will flash know which square to attach to?

             

            i hope my question is clear lol

            • 3. Re: drag and drop to grid AS2
              kglad Adobe Community Professional & MVP

              that doesn't sound like drag and drop.

               

              but if you want to attach something to a clicked cell, just do it.  flash will know which cell was clicked the same way it knows which button in a list of several buttons were clicked:

               

              for(var i:Number=0;i<colNum;i++){

              for(var j:Number=0;j<rowNum;j++){

              var mc:MovieClip=this.attachMovie("cell_mc","cell_"+j+"_"i,this.nextHighestDepth());

              mc.colNum=j;

              mc.rowNum=i;

              mc._x=j*mc._width;

              mc._y=i*mc._height;

              mc.onRelease=function(){

              //do whatever

              }

              }

              }