# Passing vars to document class

**URL:** <https://forum.kirupa.com/t/passing-vars-to-document-class/307591>\
**Category:** Uncategorized\
**Created:** [April 6, 2010, 2:07pm UTC](https://forum.kirupa.com/t/passing-vars-to-document-class/307591 "2010-04-06T14:07:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Navarone](https://avatars.discourse-cdn.com/v4/letter/n/f9ae1b/32.png) [@Navarone](https://forum.kirupa.com/u/Navarone)\
**Post date:** [April 6, 2010, 2:07pm UTC](https://forum.kirupa.com/t/passing-vars-to-document-class/307591/1 "2010-04-06T14:07:47Z")

</div>

I am trying to pass variables from key frames to my document class but I am not having much success. This is my package which starts by playing a voice over and when the voice over is done, it moves to the next frame in the movie.

```auto

package {
    import flash.display.MovieClip;
    import flash.net.URLRequest;
    import flash.media.*;
    import flash.events.*;

    public class PlayVoiceOvers extends MovieClip {
        private var VSound:Sound = new Sound();        
        private var channel:SoundChannel = new SoundChannel();        
        private var voiceToPlay:String="Voices/v001.mp3";
        private var frameToPlay:String="v2";
        private var req:URLRequest=new URLRequest(voiceToPlay);        
        private var context:SoundLoaderContext=new SoundLoaderContext(500,true);
        
        private var newreq:URLRequest = new URLRequest(voiceToPlay); 
        
        public function PlayVoiceOvers() {
            trace(voiceToPlay);
            VSound.load(req, context);
            channel=VSound.play();
            channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler, false, 0, true);
        }

        public function soundCompleteHandler(event:Event):void {
            //trace(frameToPlay);//"v2"
            gotoAndPlay(frameToPlay);
            trace(voiceToPlay);
            trace(frameToPlay);
            PlayMyNextSound();
        }
        
        public function PlayMyNextSound(){                                
            newreq=new URLRequest(voiceToPlay)
            VSound.load(newreq, context);
            channel=VSound.play();
            channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler, false, 0, true);;            
        }
        
    }
}

```

On the next frame of the movie I have this code. The idea is that once the voice over is done playing it advances to the next frame but it doesn’t appear to be working. What am I doing wrong?

```auto

stop();

voiceToPlay = "Voices/v002.mp3";
frameToPlay = "v3";

```

I get this error:

Error: Error #2037: Functions called in incorrect sequence, or earlier call was unsuccessful.  
at flash.media::Sound/\_load()  
at flash.media::Sound/load()  
at PlayVoiceOvers/PlayMyNextSound()  
at PlayVoiceOvers/soundCompleteHandler()
