2 Replies Latest reply on Jul 28, 2011 1:00 PM by juresti

    Puzzle Complete

    juresti Level 1

      I created a drag and drop kind of game.

       

      Each item has the code below. How do I set the game to complete once the user has placed all the pieces where they belong?

       

      holder_mc0.onRelease = function(){
          holder_mc0.stopDrag();
              if ((eval(this._droptarget) == string02)) {
              this.onTarget=true;
              string02.gotoAndStop(2);
              boxes.box02._visible = false;
              this._visible = false;
              number04._visible = false;
              menu_txt0._visible = false;
              zoom0._visible = false;
              zoomimage0._visible = false;
              main_txt2.setNewTextFormat(mainText);
              main_txt2.text = $parsedObject.tool[0].name
              trace("WT");
      }else
      {
              this.onTarget=false;
          }}

        • 1. Re: Puzzle Complete
          juresti Level 1

          holder_mc0.onRelease = function(){
              holder_mc0.stopDrag();
                  if ((eval(this._droptarget) == string02)) {
                  this.onTarget=true;
                  string02.gotoAndStop(2);
                  boxes.box02._visible = false;
                  this._visible = false;
                  number04._visible = false;
                  menu_txt0._visible = false;
                  zoom0._visible = false;
                  zoomimage0._visible = false;
                  main_txt2.setNewTextFormat(mainText);
                  main_txt2.text = $parsedObject.tool[0].name
                  test == (test++)
                  trace(test);
                  if (test == 1)
          {

           

                  gotoAndStop(4);
             
          }else
          {
             
              }
          }else
          {
                  this.onTarget=false;
              }}I think I got it.

           

          I just added the following:

          • 2. Re: Puzzle Complete
            Ned Murphy Adobe Community Professional & MVP

            There are a variety of ways you could approach it, but it pretty much boils down the having some sort of tally that you work thru.  In your case, each time you drop an object, you could loop thru all of the objects that need to be dropped to see if their onTarget property is true for all of them... that's assuming that property means what it seems to mean

            1 person found this helpful