# Make sound start secs later from its actual begining?

**URL:** <https://forum.kirupa.com/t/make-sound-start-secs-later-from-its-actual-begining/249559>\
**Category:** flash\
**Created:** [January 20, 2008, 4:41am UTC](https://forum.kirupa.com/t/make-sound-start-secs-later-from-its-actual-begining/249559 "2008-01-20T04:41:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![schammy79](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@schammy79](https://forum.kirupa.com/u/schammy79)\
**Post date:** [January 20, 2008, 4:41am UTC](https://forum.kirupa.com/t/make-sound-start-secs-later-from-its-actual-begining/249559/1 "2008-01-20T04:41:25Z")

</div>

Hey there!

I have the script below from a tutorial, and I want to make my track start 30 seconds from its actual beginning, in order to make it fit my swf better. I know it’s gotta be a silly detail but I’m new to Actionscript and after all that coding, I’m kinda bummed. :panda: So please, HELP! Thank you already! 🙂

################### SCRIPT #############################  
[SIZE=2]stop();  
//  
import mx.transitions._;  
import mx.transitions.easing._;  
//  
// Initial Variables  
//  
var mySound:Sound = new Sound(this);  
var volControl:Object = new Object({vol:100});  
var curPos:Number = 30;  
//  
// Main Function  
//  
function fadeVolume(target:String):Void {  
switch (target) {  
case “UP” :  
var targetVol:Number = 100;  
break;  
case “DOWN” :  
var targetVol:Number = 0;  
break;  
default :  
return;  
}  
//  
// initiate a few variables:  
// one to set an interval and set our sound’s volume,  
// the number of seconds the fade should last,  
// and finally the tweening function to use.  
var timer:Number = setInterval(changeVolume, 100);  
var duration:Number = 3;  
var easeType:Function = Regular.easeOut;  
//  
// this quick and dirty function will actually set the volume for us  
// since we can’t access the volume without the setter method.  
function changeVolume():Void {  
mySound.setVolume(volControl.vol);  
}  
var myListener:Object = new Object();  
myListener.onMotionFinished = function() {  
// when the tween is done,  
// if we just turned the volume down, stop the sound,  
// and store its current position.  
if (target == “DOWN”) {  
mySound.stop();  
curPos = mySound.position/1000;  
}  
// in any case,  
// set the sound’s volume to the target level  
// and clear the interval.  
mySound.setVolume(targetVol);  
clearInterval(timer);  
};  
var volTween:Tween = new Tween(volControl, “vol”, easeType, volControl.vol, targetVol, duration, true);  
volTween.addListener(myListener);  
}  
//  
// Button (actually a movie clip used as a button) Actions  
//  
volume\_mc.onRelease = function() {  
switch (mySound.getVolume()) {  
// if the volume is all the way up, turn it down  
case 100 :  
fadeVolume(“DOWN”);  
break;  
// if the volume is all the way down, crank it up  
case 0 :  
mySound.start(curPos,0);  
fadeVolume(“UP”);  
break;  
// if the volume’s in between, don’t do nothin’  
default :  
return;  
}  
};  
//  
// Load the Sound  
//  
mySound.loadSound(“music.mp3”,true);  
//  
};

[/SIZE]
