# Is this a Recursive Function? Help please

**URL:** <https://forum.kirupa.com/t/is-this-a-recursive-function-help-please/184343>\
**Category:** Uncategorized\
**Created:** [April 4, 2006, 2:58pm UTC](https://forum.kirupa.com/t/is-this-a-recursive-function-help-please/184343 "2006-04-04T14:58:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timB](https://avatars.discourse-cdn.com/v4/letter/t/3e96dc/32.png) [@timB](https://forum.kirupa.com/u/timB)\
**Post date:** [April 4, 2006, 2:58pm UTC](https://forum.kirupa.com/t/is-this-a-recursive-function-help-please/184343/1 "2006-04-04T14:58:00Z")

</div>

Hello all,

I have a movie with 5 buttons in it. Now, when a button is rolled over, it has an on state, and when clicked, it has an inactive state. Instead of writing alot of redundant code, I’m trying to see if I can simplify it. Here is what I have:

> 

//active/inactive  
function active (navClip) {  
if (this.hitTest = true) {  
navClip.onEnterFrame = function () {  
this.enabled = false;  
};  
} else if (this.hitTest = true) {  
navClip.onEnterFrame = function () {  
this.enabled = true;  
};  
}  
}  
// button code  
myBtn1.onRelease = function () {  
active (myBtn1);  
goToAndPlay some clip I have on stage  
};

myBtn2.onRelease = function () {  
active (myBtn2);  
goToAndPlay some clip I have on stage  
};

All AS is in the root, first frame. Any help would be GREATLY appreciated!!

Many Thanks in advance!

J

---

<div class="post-metadata">

**Author:** ![devonair](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@devonair](https://forum.kirupa.com/u/devonair)\
**Post date:** [April 4, 2006, 3:40pm UTC](https://forum.kirupa.com/t/is-this-a-recursive-function-help-please/184343/2 "2006-04-04T15:40:31Z")

</div>

Well, to answer the question, no that is not recursive… A recursive function basically calls itself repeatedly until something stops it… I’m not entirely sure what you’re doing, but this might help:

[AS]var selectedButton:MovieClip;  
//  
function buttonAction(buttonPressed:MovieClip, mcToPlay:MovieClip, frameToPlay:String):Void {  
selectedButton.enabled = true;  
buttonPressed.enabled = false;  
selectedButton = buttonPressed;  
mcToPlay.gotoAndPlay(frameToPlay);  
}  
// button code  
myBtn1.onRelease = function() {  
buttonAction(this, some\_mc, “myFrameLabel”);  
};  
myBtn2.onRelease = function() {  
buttonAction(this, someOther\_mc, “myFrameLabel”);  
};[/AS]

Also, be sure to watch the difference between the assignment operator and the equality operator when writing your scripts… it’s tricky…

---

<div class="post-metadata">

**Author:** ![timB](https://avatars.discourse-cdn.com/v4/letter/t/3e96dc/32.png) [@timB](https://forum.kirupa.com/u/timB)\
**Post date:** [April 4, 2006, 5:51pm UTC](https://forum.kirupa.com/t/is-this-a-recursive-function-help-please/184343/3 "2006-04-04T17:51:01Z")

</div>

This works great, Thank You. It doesm’t seem to send the ‘myBtn’ clips back to their default speces… in other words, they stay on “[COLOR=#FF0000]myFrameLabel” [COLOR=Black]once they’ve been clicked…

Again, Many Thanks  
[/COLOR][/COLOR]
