Skip to main content
Known Participant
February 13, 2012
Question

Trouble with an escape the room game.

  • February 13, 2012
  • 1 reply
  • 730 views

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;

          }

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
February 13, 2012

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

}

Known Participant
February 13, 2012

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

kglad
Community Expert
Community Expert
February 13, 2012

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