3 Replies Latest reply on Feb 13, 2012 8:38 AM by kglad

    Trouble with an escape the room game.

    maxus phinus Level 1

      This part that I'm working on consists of trading a hobo some twine for his alcohol. I'm trying to get the twine to disappear with dropped on the hobo, as well as the alcohol he is holding, which makes the twine leave my inventory and replaces it with the alcohol. So for I can get the twine to disappear correctly, but the alcohol can appear and disappear in some instances when I don't want them to.

       

      here's the code on the twine in the inventory

      onClipEvent (load) {

                this.tabEnabled = false;

                this._visible = false;

                orig_x = this._x;

                orig_y = this._y;

      }

      on (press) {

                this.startDrag();

      }

      on (release) {

                this.stopDrag();

                if (eval(this._droptarget) == this._parent.hobo.hobogive) {

                               _global.hobobooze = 1

                               _global.alcohol = 1

                               this._visible = false;

                               this._root.inv_alcohol._visible = true;}

      }

       

       

       

       

      on (release) {

                this.stopDrag();

                this._x = orig_x;

                this._y = orig_y;

                if (eval(this._droptarget) == undefined)

                     this._visible = true;

                     this._root.inv_alcohol._visible = false;

                     //if i don't have the last line then

                     //the alcohol appears no matter where i drag the twine

      }

       

      What i have for the alcohol in the inventory

       

       

      onClipEvent (load) {

                  this.tabEnabled = false;

                  this._visible = false;   

      }

       

      and what is on the alcohol the hobo is holding

       

      onClipEvent (load) {

                this.tabEnabled = false;

                if (_global.hobobooze == 0)

                {this._visible = true;

                }

                if (_global.hobobooze == 1)

                {this._visible = false;

                }

      }

       

        • 1. Re: Trouble with an escape the room game.
          kglad Adobe Community Professional & MVP

          1.  you shouldn't have any code attached to objects.

           

          2.  your twine's first on(release) does nothing.  to remedy, replace:

           

          on (release) {

                    this.stopDrag();

                    if (eval(this._droptarget) == this._parent.hobo.hobogive) {

                                   _global.hobobooze = 1

                                   _global.alcohol = 1

                                   this._visible = false;

                                   this._root.inv_alcohol._visible = true;}

          }

           

          on (release) {

                    this.stopDrag();

                    this._x = orig_x;

                    this._y = orig_y;

                    if (eval(this._droptarget) == undefined)

                         this._visible = true;

                         this._root.inv_alcohol._visible = false;

                         //if i don't have the last line then

                         //the alcohol appears no matter where i drag the twine

          }

           

          //with

           

           

           

           

          on (release) {

          if (eval(this._droptarget) == this._parent.hobo.hobogive) {

                                   _global.hobobooze = 1

                                   _global.alcohol = 1

                                   this._visible = false;

                                   this._root.inv_alcohol._visible = true;}

           

           

                    this.stopDrag();

                    this._x = orig_x;

                    this._y = orig_y;

                    if (eval(this._droptarget) == undefined)

                         this._visible = true;

                         this._root.inv_alcohol._visible = false;

                         //if i don't have the last line then

                         //the alcohol appears no matter where i drag the twine

          }

          1 person found this helpful
          • 2. Re: Trouble with an escape the room game.
            maxus phinus Level 1

            that cleans up my code, but i'm still experiencing the same problems with the alcohol not appearing in my inventory on que. i figured out what was wrong with the bottle the hobo is holding so i'm trying to work around that

            • 3. Re: Trouble with an escape the room game.
              kglad Adobe Community Professional & MVP

              check your logic.  use the trace() function to see what flash is doing.

              1 person found this helpful