A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: sound problem when going from 1 scene to another!

  1. #1
    Member
    Join Date
    Jul 2002
    Location
    israel
    Posts
    35
    i have this functions in flash mx:
    function playSound(soundName, soundLength) {
    gSound = new Sound();
    gSound.attachSound(soundName);
    gSound.start(0, 0);
    gSoundendTime = getTimer()+gSound.duration;
    }
    function stopSound() {
    gSound.stop();
    }
    function playBgSound(soundName) {
    gBgSound = new Sound();
    gBgSound.attachSound(soundName);
    gBgSound.start(0, 999);
    gBgSound.setVolume(gSound.getVolume()-80);
    }
    function stopPlayBgSound() {
    gBgSound.stop();
    }

    when i start in the first scene i play playSound("scene1")
    and i play playBgSound("bgSound") so far so good!
    but when i go from scene 1 to scene 2 i do stopSound() (beacuse if a sound of scene 1 is in the middle i want to stop it!!!). but what happens is not only that the sound stop's but the background sound stop's as well!!!
    and if i dont do stopSound() the background sound keep's on playing!why?what can i do sothat the bg sound will keep on playing?
    thnaks in advance
    peleg

  2. #2
    I don't know that much about controlling the sound with action script but don't use a function unless it is going to make your project more felxible. Having a function to play the sound is really defeating the purpose of the built in play method. Are you planning on building on those functions with arguments? I see those functions and am puzzled as to why you would need them.

  3. #3
    Member
    Join Date
    Jul 2002
    Location
    israel
    Posts
    35
    i dont understand the problem?
    i am using a "global sound function"
    beacuse instead of 40 time write the line's that in the playSound() function i just call it from where i need!!!!
    that's the most corrct way that a programmer should work!

    the problem that i can't figure out is :
    why do i have 2 sound objects :
    gSound and gBgSound
    and when i do gSound.Stop() it stops all the sound and not just the sound in gSound ?!

  4. #4
    Member
    Join Date
    Jul 2002
    Location
    israel
    Posts
    35

    Post ok found an answer!

    beacuse i did gSound.Stop() and didn't do gSound.Stop("soundName") i actually stoped all the sound's and not a specific one!
    it work's dor sure for flash mx (not sure for previouse version's)
    Peleg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center