PDA

View Full Version : sound problems in my tile based game...Help!



paoloissic
June 11th, 2005, 02:53 PM
im having problems putting sounds in my flash game....im using flash MX and im making a tile based RPG game:link: ....i got the background music playing in the first map...but when my character enters the second map, the music stops and play all over again in the beginning.....i want the music to be continously playing while the character is on map 1 and map 2...how can i remedy this?
im using this simple A.S for the bg music in map 1:

function buildMap(map) {
stopAllSounds();
forest = new Sound();
forest.attachSound("forest");
forest.start();


i tried to remove the line stopAllSounds();....as a result, the music became overlapping when the character transfers from one map to another...please help me with this one....

Also..is there any other way to make maps easier?...coz ryt now im using 2-dimensional arrays for my map....i only have two 640x480 maps now and it's starting to get confusing editing them...what more if i have more that 10 maps....aaaaaarrrrrggghhhhh:worried: ...by the way im using 32x32 tile sizes
Pease i really need some help here

ghjr
June 11th, 2005, 05:14 PM
You can't place the sound codes on the buildMap function, because you are probably calling the buildMap function everytime you change maps.

What you need to do is place the sound stuff right at the beginning of the whole game. For example put this wherever you want the sound to start:



this.createEmptyMovieClip("soundHolder_mc",this.getNextHighestDepth());
forest = new Sound("soundHolder_mc");
forest.attachSound("forest");
forest.start();



Cheers!

paoloissic
June 11th, 2005, 10:28 PM
You can't place the sound codes on the buildMap function, because you are probably calling the buildMap function everytime you change maps.

What you need to do is place the sound stuff right at the beginning of the whole game. For example put this wherever you want the sound to start:



this.createEmptyMovieClip("soundHolder_mc",this.getNextHighestDepth());
forest = new Sound("soundHolder_mc");
forest.attachSound("forest");
forest.start();


Cheers!


Thnks..ur code worked...i placed it before my buildmap function......but what if i want to play a different music in map 2....so in my map 1 the bg music is "forest" ....and in my map 2 i want my bg music to be "shop"...can i still use the same code? how am i gonna do it?

ghjr
June 12th, 2005, 10:59 AM
Whenever you want a different sound to startm put this on the frame:



forest.stop();
forest.attachSound("newSoundFromLibrary");
forest.start();


Or create a new sound object like this:



forest.stop();
newSoundObject = new Sound("soundHolder_mc");
newSoundObject.attachSound("newSoundFromLibrary");
newSoundObject.start();



Cheers!