# SoundChannel Problem

**URL:** <https://forum.kirupa.com/t/soundchannel-problem/302704>\
**Category:** flash\
**Created:** [January 6, 2010, 7:33am UTC](https://forum.kirupa.com/t/soundchannel-problem/302704 "2010-01-06T07:33:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrMaxMad](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@DrMaxMad](https://forum.kirupa.com/u/DrMaxMad)\
**Post date:** [January 6, 2010, 7:33am UTC](https://forum.kirupa.com/t/soundchannel-problem/302704/1 "2010-01-06T07:33:06Z")

</div>

HI,  
I am trying to make a sound seek bat, which works fine the only problem is that when i press and release aka(MOUSE\_DOWN , MOUSE\_UP), the sound plays again and again , so after few click i can hear same music playing at several different time

```auto
var _soundurl:String = "music.mp3";
var _sound:Sound = new Sound();
var _channel:SoundChannel;
var _position:Number;
var _rectangle:Rectangle;

_sound.addEventListener(Event.COMPLETE, loadComplete);
_sound.load(new URLRequest(_soundurl));

function loadComplete(eve:Event):void
{
	_channel = new SoundChannel();
	_channel = _sound.play();
	_channel.addEventListener(Event.SOUND_COMPLETE, soundComplete);
	_rectangle = new Rectangle(0,0,seek_mc.bar_mc.width,0);
	seek_mc.addEventListener(Event.ENTER_FRAME, doEnterFrame);
}

function soundComplete(eve:Event):void
{
	_channel = _sound.play();
}

seek_mc.seeker_mc.addEventListener(MouseEvent.MOUSE_UP, doMouseUp);
stage.addEventListener(MouseEvent.MOUSE_UP, doMouseUp);
seek_mc.seeker_mc.addEventListener(MouseEvent.MOUSE_DOWN, doMouseDown);

function doEnterFrame(eve:Event):void
{
	var _soundpercent:Number = _channel.position/_sound.length;
	seek_mc.seeker_mc.x = _soundpercent * seek_mc.bar_mc.width;
	
	
	
	info_txt.htmlText = ""

	//trace (_soundpercent * seek_mc.bar_mc.width);
}

function doMouseDown(eve:MouseEvent):void
{
	seek_mc.removeEventListener(Event.ENTER_FRAME, doEnterFrame);
	seek_mc.seeker_mc.addEventListener(MouseEvent.MOUSE_MOVE, doMouseMove);
	seek_mc.seeker_mc.startDrag(false,_rectangle);
	_channel.stop();
}

function doMouseUp(eve:MouseEvent):void
{
	seek_mc.addEventListener(Event.ENTER_FRAME, doEnterFrame);
	seek_mc.seeker_mc.removeEventListener(MouseEvent.MOUSE_MOVE, doMouseMove);
	seek_mc.seeker_mc.stopDrag();
	_channel = _sound.play(_position);
}

function doMouseMove(eve:MouseEvent):void
{
	var _diff:Number = eve.currentTarget.x/seek_mc.bar_mc.width;
	_position = _sound.length*_diff;
	//info_txt.htmlText = String(_channel.position) + " : " + String(_sound.length);
	_channel.stop();
}

```
