Changing volume using mouse position

Hi i am trying to create a soundscape of a photograph by making the volume of a sound increase as the cursor moves over a part of the photo which would make that sound. I am only interested in the X axis of the mouse position and know what I want my program to do but im having trouble coding it correctly.

if courser position X is less than 200 pixels, volume = 0
if courser position X is more than 400 pixels, volume = 0
if between 200 and 300 pixels volume = 1 - (mouseY - 200) /100
if between 300 and 400 pixels volume = (mouseY) - 300 / 100

I have found an example code which does a similar thing but as I attempt to include if and else statements the program does not respond how I expect.

Example code,

var snd:Sound = new Sound();
snd.load(new URLRequest(“song.mp3”));

var channel:SoundChannel = new SoundChannel();
channel = snd.play();

var trans:SoundTransform = new SoundTransform();

this.addEventListener(Event.ENTER_FRAME, onLoop, false, 0, true);

function onLoop(evt:Event):void {
trans.volume = 1 - mouseY/stage.stageHeight;
channel.soundTransform = trans;
}

Any suggestions or a point in the right direction would be apreciated