3 Replies Latest reply on Feb 15, 2010 7:14 AM by Gregory Lafrance

    Drag and Drop help

    choisington Level 1

      I have an elaborate drag and drop question.

       

      I have various icons that I drag on to a stage. Some icons need to be allowed to be dropped 10 times and some only 2 and some only 1.

       

      I need to figure out a way to say "if the same icon has already been dropped twice (or once or 10 times) do not drop again".

       

      He is a sample of my code. Straight forward but it is something in the if else statement I need to fix.

       

      numChildren does not really work for this because there can be different icons. Such as icon A and icon B. I want icon A to be allowed to be dropped 10 times but not icon B.

       

       

      if (dropBox1.numChildren == 0)
                              {
                              img = new Image();
                              img.source = (event.dragInitiator as Image).source;
                              img.addEventListener(MouseEvent.MOUSE_DOWN, doDragStart);
                              img.addEventListener(MouseEvent.MOUSE_DOWN);
                              img.buttonMode = true;
                           
                              dropBox1.addChild(img);
                              }
                              else if (dropBox1.contains(event.dragInitiator.parent as UIComponent))
                              {
                              img = new Image();
                              img.source = (event.dragInitiator as Image).source;
                              img.addEventListener(MouseEvent.MOUSE_DOWN, doDragStart);
                              img.addEventListener(MouseEvent.MOUSE_DOWN);
                              img.buttonMode = true;
                          
                              dropBox1.addChild(img);
                              }