# Problems with "Recursive function"

**URL:** <https://forum.kirupa.com/t/problems-with-recursive-function/161923>\
**Category:** flash\
**Created:** [September 8, 2005, 9:30am UTC](https://forum.kirupa.com/t/problems-with-recursive-function/161923 "2005-09-08T09:30:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pup\_100](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pup\_100](https://forum.kirupa.com/u/Pup_100)\
**Post date:** [September 8, 2005, 9:30am UTC](https://forum.kirupa.com/t/problems-with-recursive-function/161923/1 "2005-09-08T09:30:20Z")

</div>

[font=Times New Roman]I’ve written a piece of practice code to make a graphic of a jet fly across the screen & leave in it’s vapour trail a name entered in a text field on the previous frame. So a user enters their name in frame 1 presses a submit button & on frame 2 a “Welcome” message appears with the jet spelling out their name.[/font]

[font=Times New Roman]What I wanted to achieve was the effect of the letters slowly “disappearing” as they would in a real vapour trail. In an “if “ condition I have said if the \_alpha of the current field is less than 30 call a recursive function on the rest of the letters, to slowly get them to disappear – it all works great BUT…. Once the current field hits the 30 \_alpha mark it stops reducing it’s own \_alpha, obviously because control has been handed over to the next field via the recursive function. How can I get round this?[/font]

[font=Times New Roman]Many thanks[/font]

[font=Times New Roman]Below is the relevant section of code from the “dim()” recursive function. Full fla also attached.[/font]

```auto
 
 
[left]function dim(field) { [/left]
[left]_root.onEnterFrame = function() { [/left]
[left] field._alpha -= 4;[/left]
[left]if (field._alpha<=20) {[/left]
[left] ount++;[/left]
[left] dim(_root["f_"+count]);[/left]
[left] [/left]
[left]}[/left]
[left] [/left]
[left]if (count>=input.length) {[/left]
[left] _root.onEnterFrame = null;[/left]
[left] [/left]
[left] }[/left]
[left] [/left]
[left]};[/left]
[left] [/left]
[left]}[/left]
 

```
