_y is bothering me

<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?

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.

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

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?

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

i’ll give it a shot.

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

   \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:

  \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.

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 ??

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.

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! ; )

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.