A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: Stop sounds causes flv to stop too

  1. #1
    Always Without Crutches!
    Join Date
    Feb 2005
    Location
    On The Interweb Thingy
    Posts
    44

    Stop sounds causes flv to stop too

    Hey Hey!

    Got a minor issue that I just can't seem to figure out. I've added piece of background music and created a simple piece of script to stop and start the music, should it irritate the user.

    All works fine, however when I'm playing an flv (imported to stage and streamed) the stop function causes the flv to stop playing. It makes no sense to me.

    Here's the code for the variable

    Code:
    var themeSound:Sound = new Sound();
    themeSound.attachSound("soundtrack")
    and the code for the On the button

    Code:
    on(release){
    	with(tracks){
    		gotoAndStop('on')
    	themeSound.start();
    	audiofx_state = 1;
    	}
    }
    and the code for the Off button

    Code:
    on(release){
    	with(tracks){
    		gotoAndStop('off')
    	themeSound.stop();
    	audiofx_state = 0;
    	}
    }
    The audiofx_state I'm using to deactivate the stop and start buttons as I have a small movie clip that changes text from on to off etc.

    So as you can see, nothing complicated here. I've never tried to do this before and any help would be appreciated.

    **EDIT**

    I work fast and found a way around this problem, but I'd still like to know why the way above doesn't work.

    To get around the problem I loaded the mp3 file for the background music from and external source rather than the library.

    Code:
    var themeSound:Sound = new Sound();
    themeSound.loadSound("sounds/theme.mp3",true);
    themeSound.setVolume(20);
    themeSound.stop();
    Code:
    on(release){
    	if (audiofx_state == 0){
    		with(tracks){
    		gotoAndStop('on')
    	soundStarted = !soundStarted;
    	audiofx_state = 1;
    	}
    	themeSound.start();
    	}
    }
    Code:
    on (release) {
    	if (audiofx_state == 1)
    	{
    		with (tracks)
    		{
    			gotoAndStop('off');
    			audiofx_state = 0;
    		}
    				themeSound.stop();
    	}
    }
    Last edited by BillyBobBongo; 07-22-2008 at 08:22 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center