# \_y is bothering me

**URL:** <https://forum.kirupa.com/t/-y-is-bothering-me/2855>\
**Category:** Uncategorized\
**Created:** [March 25, 2002, 4:12am UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855 "2002-03-25T04:12:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2002, 4:12am UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/1 "2002-03-25T04:12:30Z")

</div>

\<font color=red \>Ha!\</font\>\<font color=blue \>Ha!\</font\>\<font color=purple \>Ha!\</font\>\<font color=orange \>Ha!\</font\>\<font color=green \>Ha!\</font\>\<font color=yellow\>Ha!\</font\>\<font color=navy \>Ha!\</font\>\<font color=maroon\>Ha!\</font\>\r\rI have an MC, and when it gets hit by something its supposed to go down down down forever. \r\rthis.\_y += yVelocity1\r\rhowever…it only goes down a little bit. this is my code\r\ronClipEvent (load) {\r xVelocity1 = 5+random(8);\r yVelocity1 = 10;\r this.\_x = -30;\r this.\_y = 80+random(300);\r}\ronClipEvent (enterFrame) {\r if (!trip) {\r this.\_x += xVelocity1;\r }\r test = this.hitTest(\_root.mine);\r if (test == true) {\r trip = true;\r this.gotoAndPlay(“explode”);\r **this.\_y += yVelocity1;** \r }\r b1 = this.hitTest(\_root.bounce);\r if (b1 == true) {\r xVelocity1 = -xVelocity1;\r this.\_y = this.\_y+random(150);\r if (this.\_y\>=385) {\r this.\_y = this.\_y-15;\r }\r }\r b2 = this.hitTest(\_root.bounce2);\r if (b2 == true) {\r xVelocity1 = -xVelocity1;\r this.\_y = this.\_y-random(150);\r if (this.\_y\<=90) {\r this.\_y = this.\_y+15;\r }\r }\r}\r\r\rthe bold part is what stops working. Is there something in my code that is somehow limiting how far the \<font color=green\>\_y\</font\> can go?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2002, 4:14am UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/2 "2002-03-25T04:14:52Z")

</div>

besides that part at the end that says::\r\r if (this.\_y \>= 380)\r\rbecause, the MC stops at like 250 or so. And, theoretically, in a perfect world, it should go until at least 380…unless…hmmmm…\r\rif anyone sees anything that is out of order let me know. if not then i know what the problem is. i’ll fix it tomorrow. for now I’m off to bed. 'nite everyoen.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2002, 6:44am UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/3 "2002-03-25T06:44:52Z")

</div>

um, the clip will only move along the \_y axis while it’s bounding box intersects with the bounding box of ‘mine’. also, once the ‘mine’ is hit, the movie will not move along the \_x axis at all.\r:) \rjeremy

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2002, 2:49pm UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/4 "2002-03-25T14:49:05Z")

</div>

right. Movement on the X should stop and it should sink to the bottom of the screen. I figured it out. It has to do with the \r\r(this.\_y \>= 380)\r\rand also the if statement for the mine. I need to make it so that once it hits the mine, “test” is forever true. because once the mine and sub stop touching, test is no longer true. how do i do that?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2002, 4:20pm UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/5 "2002-03-25T16:20:42Z")

</div>

why don’t you just NOT use clip events and make different loops within the movie?\r:) \rjeremy

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2002, 4:38pm UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/6 "2002-03-25T16:38:14Z")

</div>

i’ll give it a shot.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2002, 9:20pm UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/7 "2002-03-25T21:20:14Z")

</div>

alternatively, you might invert the way you’re testing as well:

```auto
   \r\ronClipEvent(enterFrame){\r\r if(trip){\r\r /* fall */\r\r }else{\r\r /* do that other stuff */\r\r }\r\r}

```

\r\rthat means it won’t continue the hittests after the initial contact.\r\r\* added a few things here\*\r\ri looked closer at the code and thought i’d make few suggestions…\r\rwhen making a boolean evaluation (check for true or false) you don’t have to write “== true”, you can simply test the condition.\r\rie. instead of if(test == true) you can write if(test)\r\ralong the same lines, there’s no reason to store the results of the hitTest in a variable, you can simply evaluate the hitTest directly.\r\rie. instead of:\rb1 = this.hitTest(\_root.bounce);\rif (b1 == true) {\r\rjust:\rif(hitTest(\_root.bounce)){\r\rwhich brings up my third (and final) point. most of the time, you don’t need to use “this”. the code will default to the MovieClip anyway. exceptions are: when you’re dealing with a regular Object instead of MovieClip (why that is so is beyond me, flash weirdness); and when using square brackets to access local variables (this[“mc”+i]).\r\rhere’s what it looks like with all of those points considered:

```auto
  \r\ronClipEvent (load) {\r\r xVelocity1 = 5+random(8);\r\r yVelocity1 = 10;\r\r _x = -30;\r\r _y = 80+random(300);\r\r}\r\ronClipEvent (enterFrame) {\r\r if (trip) {\r\r _y += yVelocity1;\r\r }else{\r\r _x += xVelocity1;\r\r if (trip = hitTest(_root.mine)) {\r\r gotoAndPlay("explode");\r\r _y += yVelocity1;\r\r }\r\r if (hitTest(_root.bounce)) {\r\r xVelocity1 = -xVelocity1;\r\r _y = _y+random(150);\r\r if (_y>=385) {\r\r _y = _y-15;\r\r }\r\r }\r\r if (hitTest(_root.bounce2)) {\r\r xVelocity1 = -xVelocity1;\r\r _y = _y-random(150);\r\r if (_y<=90) {\r\r _y = _y+15;\r\r }\r\r }\r\r }\r\r}

```

\rnote how we’re setting and checking the “trip” variable all in one go in that if statement.\r\rhope it’s helpful and not just superfluous condescending conceit. ; )\r\rcheers.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2002, 10:30pm UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/8 "2002-03-25T22:30:46Z")

</div>

My dear Supra, one thing that may save your life sometimes… In Flash MX, you HAVE TO PUT this. in front of your properties. Flash MX seems to handle everything as objects now (hail C++ !), and this may be the cause of numerous mistakes and incompatibilities between MX and 5’s flas.\r\rpom 0] \r\rBy the way, how is it going for you with MX ??

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2002, 11:05pm UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/9 "2002-03-25T23:05:47Z")

</div>

thanks supra. Oh supra. Just so you know, for the gotoAndPlay, it wouldn’t read the code unless there was a “this.” in front of it.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2002, 12:08am UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/10 "2002-03-26T00:08:08Z")

</div>

ily,\r\rhaven’t perused it yet. and thanks to that little tidbit of info you’ve offered i’ll layoff trying it until i’ve finished this project. i wouldn’t savour adding “this” to every single method i’m using.\r\rthat’s something that bothered me about flash 5, movieclips are _supposed_ to be objects but aren’t consistent with their behaviours. i wish they’d gone the other way though, and made an object look locally first and through its prototypes before trying \_root. you end up with thousands of this’s all over the place.\r\ri’m excited about the dynamic jpegs and mp3s, and i understand you can draw lines and shapes programmatically too! about bloody time. wish i could have done that with the 3d engine i was working with. maybe if i revisit it i’ll try converting to that method.\r\rnot jubba,\r\rthat’s bizarre, perhaps you’re using mx too?\r\ri guess i’d better upgrade before i give any more bad advice! ; )

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2002, 3:15am UTC](https://forum.kirupa.com/t/-y-is-bothering-me/2855/11 "2002-03-26T03:15:02Z")

</div>

no i’m using 5. but the clip wouldn’t go to the targeted frame unless I had “this.gotoAndPlay” i thought that was odd to seeing as it worked without on everything else…oh and that code worked perfectly supra…thanks again.
