dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: How do I get sound/music to keep playing through a scene trasition.

Hybrid View

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    10

    Question How do I get sound/music to keep playing through a scene trasition.

    I'm trying to build a sort of flash based portfolio that will allow the user to control what they view. I want some background music to play under all of this, but when the user goes to a particular scene or frame of animation the music will stop or skip as they move.

    Is there a way to get the music to just play in the background in an endless loop regardless of which scene or frame they jump to or another way to get a similar effect? I'd really like it to be interactive rather than just a preset slide show.

  2. #2
    flash grasshopper
    Join Date
    Feb 2005
    Posts
    156
    I only know how to do this in Actionscript 2.0, though I suspect the same principle would also work in Actionscript 3.0.

    Basically you use AS to control the sound, so in AS 2.0 you could do it like this:
    PHP Code:
    function playClips ()
    {
        
    bgmusic = new Sound ();
        
    bgmusic.attachSound("music");
        
    bgmusic.start();
        
        
    bgmusic.onSoundComplete = function ()
        {
            
    loopClips();
        }
    };

    function 
    loopClips ()
    {
        
    bgmusic.start ();
    };

    playClips(); 
    Then you would just have to make sure that under the properties of your sound in the library (in this case, called "music") Export for Actionscript is checked, and that either Export in first frame is also checked, or that you briefly put your sound somewhere on the timeline before the script - say, in a keyframe on frame 2 (and only frame 2).

    Since your music is controlled by Actionscript, it isn't affected by any timeline movements.

    Also you should note that Scenes are not appropriate to use as a navigational technique. It's tempting and it seems to make sense, but actually they screw withe your Actionscript a lot. Use labelled frames instead.

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    10
    Thanks for the tip.

    As it turned out, once I dug through the settings, I found that I had it almost perfectly set up already.

    Once I set it to go to frame 2 instead of frame 1 it started working.

    This caused the music to start on a continuous uninterrupted loop without it restarting or getting a doubling effect.

    It stays on, with out skipping or stopping, even when I jump to another frame or scene.

    I've set some labeled frames up for transitions, but should I still use separated fame sections instead of scenes, even if I'm setting up 4 different places for this to lead?

    Also, is there an easy way (or even a hard way) to get an animation to play uninterrupted in the background? I have this macro scale picture of a floating seed that is multi-colored and is sweeping through hue changes so that the colors cycle. I'd like this to become something that goes uninterrupted regardless of frame.
    Last edited by JackVogel; 02-11-2010 at 10:58 AM.

  4. #4
    flash grasshopper
    Join Date
    Feb 2005
    Posts
    156
    You should definitely use frames instead of scenes - even if your code is currently working, you may find as you add complexity it stops working, or just that once in a while it doesn't work how it should.

    An easy way to make an animation in the background is by animating within a movieclip symbol - as in, you have your tweens on the timeline of the symbol, rather than on the main timeline. Then if you add your symbol to the main timeline, without any keyframes, it will continue to play regardless of where the playhead is at.

  5. #5
    Junior Member
    Join Date
    Feb 2010
    Posts
    10
    Thanks. I'll have to try putting it into a movie once I can get back into the computer lab. The arrangement of class days combined with the snowfall here in Maryland have made it so that it will have been 2 weeks since I was last able to work on my project, LOL.

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