# I can't solve an Action Script Error

**URL:** <https://forum.kirupa.com/t/i-cant-solve-an-action-script-error/266427>\
**Category:** flash\
**Created:** [July 20, 2008, 11:35am UTC](https://forum.kirupa.com/t/i-cant-solve-an-action-script-error/266427 "2008-07-20T11:35:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaimesilva](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jaimesilva](https://forum.kirupa.com/u/jaimesilva)\
**Post date:** [July 20, 2008, 11:35am UTC](https://forum.kirupa.com/t/i-cant-solve-an-action-script-error/266427/1 "2008-07-20T11:35:10Z")

</div>

Hi.

I’m making a Catalogue to be distributed on a CD, and I want to provide an elegant way to exit the Catalogue.  
So I made a separate “exit.swf” movie to be loaded over the main catalogue movie.  
it have a dark transparency and a goodbye message. Looks very good.  
Also, at the same time I want that the background music fade out smoothly until the movie exits.  
To achieve this I had put an event .wav sound on a frame at the begining of the movie, with an instance of a “back music” movie clip on the same frame.  
Also I have this code on the same frame:

```auto
// create Sound object
globalsound = new Sound(); globalsound.setVolume(100);

```

If I wanted to fade out the background music, I only have to put this code before an exit frame:

```auto
// create Sound object
var snd:Sound = new Sound(music);
trace(music);
// start fade
this.onEnterFrame = function() {
 // get current volume
 var vol:Number = snd.getVolume();
 // if volume is larger than 0, decrease it, otherwise stop fade
 if (vol>0) {
  snd.setVolume(vol-3);
 } else {
  delete this.onEnterFrame;
 }
};

```

But, because I want that the “Exit” button do all the things, no mather were in the movie the user is, I thought I may put all the instructions on the same button.

So, I want the “exit” button to load the #exit.swf" movie and at the same time fade out the music and exit the movie.

I tryed the following code on the button:

```auto
on (release) {
 loadMovieNum("imagens/exit.swf", 1);
 }
 // create Sound object
 var snd:Sound = new Sound(music);}
 trace(music);
    {
    }// start fade
 this.onRelease = function();
 // get current volume
    }
 var vol:Number = snd.getVolume();
 {
    }// if volume is larger than 0, decrease it, otherwise stop fade
 if (vol>0) {
  snd.setVolume(vol-3);
 } else {
  delete this.onRelease;
 }
}

```

But it gives me one (1) error on Line 5.  
I had spent hours making tests and I can’t figure out what’s wrong.  
I’m not a Action Script guru; I only search for code and try to adapt to my projects.

Note that I changed the

**this.onEnterFrame**

to

**this.onRelease**

Could someone please help me to find the error?

Thank you
