# On (release); Please Stop Mc! Urgent!

**URL:** <https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358>\
**Category:** Uncategorized\
**Created:** [June 15, 2008, 12:49am UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358 "2008-06-15T00:49:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![outback](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@outback](https://forum.kirupa.com/u/outback)\
**Post date:** [June 15, 2008, 12:49am UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358/1 "2008-06-15T00:49:04Z")

</div>

Hey Everybody,  
I need to create a btn that disable the following code:

```auto
 
onMouseMove = function () {
 i++;
 distX = iniX-_xmouse;
 distY = iniY-_ymouse;
 distTotal = Math.sqrt(distX*distX+distY*distY);
 if (distTotal>dist) {
  iniX = _xmouse;
  iniY = _ymouse;
  np = attachMovie("p", "p"+i, i);
  np._xscale = np._yscale=Math.random()*150+50;
  np.ang = Math.random()*360;
  np.velX = .1;
  np.velY = .1;
  np._x = _xmouse;
  np._y = _ymouse;
  np.onEnterFrame = move;
 }
};

```

Can anyone please help???

Tks!!!

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 15, 2008, 1:18am UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358/2 "2008-06-15T01:18:19Z")

</div>

```auto
my_btn.onPress = function() {
if (onMouseMove != undefined) {
delete onMouseMove;
}
};

```

---

<div class="post-metadata">

**Author:** ![outback](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@outback](https://forum.kirupa.com/u/outback)\
**Post date:** [June 15, 2008, 1:26am UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358/3 "2008-06-15T01:26:17Z")

</div>

Thanks man…u saved my life!!!

u r the man!!!

it worked~

---

<div class="post-metadata">

**Author:** ![outback](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@outback](https://forum.kirupa.com/u/outback)\
**Post date:** [June 15, 2008, 1:31am UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358/4 "2008-06-15T01:31:04Z")

</div>

😑 Now I’m almost there…

is there any thing I can do to make the MC come back?

Tks

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 15, 2008, 2:20am UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358/5 "2008-06-15T02:20:32Z")

</div>

```auto
my_btn.onPress = function() {
	if (onMouseMove != undefined) {
		delete onMouseMove;
	} else if (onMouseMove = undefined) {
		onMouseMove = function () {
			// chuck all the onMouseMove code in here
		};
	}
};

```

Can’t guarantee it will work, but give it a try.

---

<div class="post-metadata">

**Author:** ![outback](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@outback](https://forum.kirupa.com/u/outback)\
**Post date:** [June 15, 2008, 2:45am UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358/6 "2008-06-15T02:45:53Z")

</div>

:crying: it’s not workink do you is there anything I can be doing wrong?

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 15, 2008, 3:00am UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358/7 "2008-06-15T03:00:16Z")

</div>

You can always try the following. Rather than using a button, use a movieclip - I’ve called it dummyMC here. Then apply the following code to your timeline:

```auto
function mouse_move() {
	i++;
	distX = iniX - _xmouse;
	distY = iniY - _ymouse;
	distTotal = Math.sqrt(distX * distX + distY * distY);
	if (distTotal > dist) {
		iniX = _xmouse;
		iniY = _ymouse;
		np = attachMovie("p", "p" + i, i);
		np._xscale = np._yscale = Math.random() * 150 + 50;
		np.ang = Math.random() * 360;
		np.velX = .1;
		np.velY = .1;
		np._x = _xmouse;
		np._y = _ymouse;
		np.onEnterFrame = move;
	}
}
dummyMC.onMouseMove = mouse_move;
dummyMC.onPress = function() {
	if (dummyMC.onMouseMove != undefined) {
		delete dummyMC.onMouseMove;
	} else {
		dummyMC.onMouseMove = mouse_move;
	}
};

```

Again, no guarantee that it will work. Essentially it creates a separate function called mouse\_move which it attaches to the dummyMC. When you press on the MC, it will delete the function, then reattach it next time it’s pressed.

---

<div class="post-metadata">

**Author:** ![outback](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@outback](https://forum.kirupa.com/u/outback)\
**Post date:** [June 15, 2008, 9:56pm UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358/8 "2008-06-15T21:56:05Z")

</div>

Something is not working…I’m uploading the \*.fla document can that be of any use?

Please help…I need to put my website online tonight!!!

Thanks for your attention…I’m hopping it can work now…tks again :hangover:

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [June 15, 2008, 10:37pm UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358/9 "2008-06-15T22:37:18Z")

</div>

It works just as I stated in the earlier post. All I’ve done is change the references to dummyMC to instance name of my\_btn. I’ve added a couple of comments to explain what the code is doing:

```auto
var iniX = _xmouse;
var iniY = _ymouse;
var dist = Math.random()*15+5, i = 0;
function mouse_move() {
	i++;
	distX = iniX-_xmouse;
	distY = iniY-_ymouse;
	distTotal = Math.sqrt(distX*distX+distY*distY);
	if (distTotal>dist) {
		iniX = _xmouse;
		iniY = _ymouse;
		np = attachMovie("p", "p"+i, i);
		np._xscale = np._yscale=Math.random()*150+50;
		np.ang = Math.random()*360;
		np.velX = .1;
		np.velY = .1;
		np._x = _xmouse;
		np._y = _ymouse;
		np.onEnterFrame = move;
	}
};
onMouseMove = mouse_move; // default state - start mouse_move function
my_btn.onPress = function() {
	if (onMouseMove != undefined) { // if onMouseMove is running
		delete onMouseMove; // cancel onMouseMove
		} else { // otherwise
		onMouseMove = mouse_move; // start onMouseMove
	}
};
function move() {
	this.velX += .5;
	this.velY += .5;
	this._x += Math.cos((this.ang-this.ang*.5)/(Math.PI/180))*this.velX;
	this._y += Math.sin((this.ang-this.ang*.5)/(Math.PI/180))*this.velY;
	this._alpha>0 ? this._alpha -= 2.5 : this.unloadMovie();
}

```

---

<div class="post-metadata">

**Author:** ![outback](https://avatars.discourse-cdn.com/v4/letter/o/9f8e36/32.png) [@outback](https://forum.kirupa.com/u/outback)\
**Post date:** [June 16, 2008, 1:59am UTC](https://forum.kirupa.com/t/on-release-please-stop-mc-urgent/263358/10 "2008-06-16T01:59:39Z")

</div>

Thanks…u really helped!!!

now it worked!!!

Best Regards and take care…

:party:
