PDA

View Full Version : mp3/sound


flawlesstwins
08-10-2006, 09:24 PM
Hi I didn't know what forum i should post this question in, I am a noob and I need some help please. I am having the hardest time trying to figure out how to get the right actionscript to make my music play automatically when my site starts. I have came up with this so far. I put the action script below. But what seems to happen is i have to press play for the sound it doesn't come on automatically, I really just wanted the music to autmatically play because i want it with my flash intro which will be several frames and then once guest got to my homepage and other pages they have the option to pause it and then play it from where it paused from. I want the music to continue to play throughout the website and not start over each time someone clicks on something on a new page on the site. I hope you can help me I would really appreciate it, I didn't know how to google this type of question. thanks so much. this is my actionscript for my initial frame


this.onEnterFrame = function () {



myMusicDurationText=_root.myMusic.duration/1000;

myMusicPositionText=_root.myMusic.position/1000;

myMusicDurationText=Math.floor(_root.Sound.duratio n/1000);

myMusicPositionText=Math.floor(_root.Sound.positio n/1000);

//loading bar

myBar=Math.floor((((_root.Sound.position)/(_root.Sound.duration))*100));







}





Sound = new Sound();

Sound.loadSound("2.mp3",true);

SoundPosition=0;

SoundVolume=50;

SoundPan=0;

Sound.setVolume(SoundVolume);

Sound.setPan(SoundPan);





}



and this is for my play button action script

on (press) {

Sound.start(SoundPosition,0);

SoundPosition=0;

}



and this for my pause button

on (press) {

//Pause button

SoundPosition=Sound.position/1000;

_root.Sound.stop();



}

billingsgate
08-11-2006, 05:00 AM
I can't really comment on what's happeing with your script, but you shouldn't use the word "Sound" to define a variable name, since Sound is reserved as the name of an object Class in Flash. It should be more like:

var myMusic:Sound = new Sound();

If you feel like starting from scratch, and doing it right, here you can find the best tutorials around for using sound in Flash:

Kenny Bellew's Sound Tutorials (http://kennybellew.cowfly.com/tutorial/)