# How to call a function in another function?

**URL:** <https://forum.kirupa.com/t/how-to-call-a-function-in-another-function/330426>\
**Category:** flash\
**Created:** [January 19, 2013, 7:10pm UTC](https://forum.kirupa.com/t/how-to-call-a-function-in-another-function/330426 "2013-01-19T19:10:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![learner\_7n](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@learner\_7n](https://forum.kirupa.com/u/learner_7n)\
**Post date:** [January 19, 2013, 7:10pm UTC](https://forum.kirupa.com/t/how-to-call-a-function-in-another-function/330426/1 "2013-01-19T19:10:49Z")

</div>

Hi,

I have the following code which I need to call it again and again. How can I create a function which can be called in another function.

```auto
MainContainer.EHSSNav.Area.addEventListener(MouseEvent.CLICK,AreaClickHandler);
function AreaClickHandler(event:MouseEvent):void {
	TweenLite.to(MainContainer.OrganizationNav, 0.5, {alpha:0});
	TweenLite.to(MainContainer.ScheduleNav, 0.5, {alpha:0});
	TweenLite.to(MainContainer.FormsNav, 0.5, {alpha:0});

	TweenLite.to(MainContainer.EHSSNav, 0.5, {y:440});
	TweenLite.to(MainContainer.OrganizationNav, 0.5, {y:440});
	TweenLite.to(MainContainer.ScheduleNav, 0.5, {y:440});
	TweenLite.to(MainContainer.FormsNav, 0.5, {y:440});

	navigateToURL (new URLRequest ("http://MyServer/info/Docs/Area.pdf"));}

MainContainer.Logistic.addEventListener(MouseEvent.CLICK,LogisticClickHandler);
function LogisticClickHandler(event:MouseEvent):void {
	TweenLite.to(MainContainer.OrganizationNav, 0.5, {alpha:0});
	TweenLite.to(MainContainer.ScheduleNav, 0.5, {alpha:0});
	TweenLite.to(MainContainer.FormsNav, 0.5, {alpha:0});

	TweenLite.to(MainContainer.EHSSNav, 0.5, {y:440});
	TweenLite.to(MainContainer.OrganizationNav, 0.5, {y:440});
	TweenLite.to(MainContainer.ScheduleNav, 0.5, {y:440});
	TweenLite.to(MainContainer.FormsNav, 0.5, {y:440});

	navigateToURL (new URLRequest ("http://MyServer/info/Docs/Logistic.pdf"));}

```

I need to call the following code several times, so how can I avoid it using one function and calling it another functions?

```auto
 TweenLite.to(MainContainer.OrganizationNav, 0.5, {alpha:0});
	TweenLite.to(MainContainer.ScheduleNav, 0.5, {alpha:0});
	TweenLite.to(MainContainer.FormsNav, 0.5, {alpha:0});

	TweenLite.to(MainContainer.EHSSNav, 0.5, {y:440});
	TweenLite.to(MainContainer.OrganizationNav, 0.5, {y:440});
	TweenLite.to(MainContainer.ScheduleNav, 0.5, {y:440});
	TweenLite.to(MainContainer.FormsNav, 0.5, {y:440});

```

Please help.
