# Calling functions within mouse event functions?

**URL:** <https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671>\
**Category:** flash\
**Created:** [March 17, 2003, 12:20am UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671 "2003-03-17T00:20:57Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![mindfriction](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mindfriction/32/172_2.png) [@mindfriction](https://forum.kirupa.com/u/mindfriction)\
**Post date:** [March 17, 2003, 12:20am UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/1 "2003-03-17T00:20:57Z")

</div>

Hi! having this small dillema,

Is it not possible to call other functions from generic mouse event functions? Surely it is !!??

ie…

```auto

_root.myButton.onPress = function(){
     hide();
}

function hide(){
   _root.myMc._visible = false;
}

```

---

<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 17, 2003, 3:45am UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/2 "2003-03-17T03:45:50Z")

</div>

It is possible… but doesn’t it call it as if it’s calling from the button. ie, wouldn’t it need to be “\_root.hide();” as the call?

just taking a guess at this point. 🙂

---

<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 17, 2003, 3:52am UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/3 "2003-03-17T03:52:45Z")

</div>

> It is possible… but doesn’t it call it as if it’s calling from the button. ie, wouldn’t it need to be “\_root.hide();” as the call?

since the function has the absolute addressing to the movie clip … it shouln’t be a problem 🙂

and if you call only one function you can use

```auto
_root.myButton.onPress = hide;

```

---

<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 17, 2003, 11:20pm UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/4 "2003-03-17T23:20:48Z")

</div>

Yeah thanks guys, but I know that you can call a function straight from the handler

```auto
 this.onPress = hide();

```

But this isnt exactly what Im looking for, should have made my post more clear… Say there are 2 different functions, (both seperate functions as they do completely different things), and I want call both at the time the mouse handler has picked up a mouse event? EG, I want to hide something with function hide(), and at the same time duplicate something else with function dupeIt().

:-\

---

<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 17, 2003, 11:48pm UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/5 "2003-03-17T23:48:41Z")

</div>

```auto
this.onPress = function() {
	hide();
	dupeIt();
}

```

🙂

---

<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 17, 2003, 11:49pm UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/6 "2003-03-17T23:49:46Z")

</div>

```auto
_root.myButton.onPress = function(){
     doThis();
     doThat();
}

```

??? I must be missing something… :trout:

---

<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 17, 2003, 11:56pm UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/7 "2003-03-17T23:56:08Z")

</div>

😛 😉

---

<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 17, 2003, 11:59pm UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/8 "2003-03-17T23:59:08Z")

</div>

You… you’re too fast… [size=1]said like Neo after Morpheus kicked his \*\*\* in the dojo[/size]

---

<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 18, 2003, 12:04am UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/9 "2003-03-18T00:04:58Z")

</div>

😛 😛 😛

yes i am 🙂 [size=1]said like morpheus after kicking neo’s \*\*\*[/size]

[size=1] **ps.** who’s morpheus? who’s neo? 😛 ;)[/size]

---

<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 18, 2003, 6:13am UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/10 "2003-03-18T06:13:38Z")

</div>

ive tried this, i figured that it should be that easy - a straight function call within the handler function. Maybe somewhere, or somehow something is interfearing but I cant figure it out for the life of me.

And in regard to Neo and Morpheus , havent u ever seen the movie The Matrix??  
😱

---

<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 18, 2003, 7:01am UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/11 "2003-03-18T07:01:20Z")

</div>

maybe if you post all your code or attach the fla 🙂

> And in regard to Neo and Morpheus , havent u ever seen the movie The Matrix??

being honest … no 😛  
it’s been like 6 years since the last time i saw a movie 😛

but i do know who’s morpheus and who’s neo 😉

---

<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 18, 2003, 9:17am UTC](https://forum.kirupa.com/t/calling-functions-within-mouse-event-functions/15671/12 "2003-03-18T09:17:09Z")

</div>

:+) …here we go…

```auto

var i=1;
...
...
...

createNodeButt.onPress = function(){

createNodeButt._alpha=100;
createEdgeButt._alpha=50;

dupeNode();//go to another function to duplicate the node (a circle shape)

}

function dupeNode()
{
  i++;
 newName = "node" + i;
 tempNode.duplicateMovieClip(newName, i);
 this._parent[newName]._xscale = 175;
 this._parent[newName]._yscale = 175;
 this._parent[newName]._x = xpos;
 this._parent[newName]._y = ypos;
}

```

There’s a snippet of my code Kax (-:

Hope is make sense. In the onPress handler function I use the \_alpha to show user that the button is selected, then I call dupeCircle function to carry out the rest of the actions.
