A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Sound problem

  1. #1
    Junior Member
    Join Date
    Sep 2009

    Question Sound problem

    Hi, i am going through an issue that i cannot solve.
    I have applied sound to my website in flash. I have different pages designed in different scenes. And sound control is present on each and every scene. I browsed through the net and found a tutorial which showed how to play background sound and keep it continuos throughout the navigation via different scenes. Inicially i had a problem where the sound restarted when i went to a new scene but now that problem is solved . My current problem is, when my site loads the music starts to play which is fine. Then when i press on the sound button to stop it . The action is to Start Sound and when i press it again It stops. But When i stop it and go to any other button and navigate to some other scene , the sound restarts.

    My guess - The sound sequence needs to be Stop on the first click and Play on the second.
    But i also want the sound to autostart when site loads. And i because i have different scenes i have applies a complicated action scrip from a tutorial.which goes as follows:-

    On the first frame of sound layer i have this action script --->

    _root.sound1 = new Sound(this);

    On the last frame of the same layer of sound i have the following script --->

    on(press) {
    if (playing != 1) {
    playing = 1
    } else {
    playing = 0;

    I am not a hardcore actionscript professional so i dont understand most of this. Though i would appreciate if someone could help me.

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002

    This should be the idea.

    Code for the first frame:
    PHP Code:
    // if the sound doesn't exist, 
    if (sound1 == undefined)
    // create it
    var sound1:Sound = new Sound (this);
    sound1.attachSound ("sound1a");
    // and start playing
    // define a variable which knows that the sound is playing
    var isPlaying true;

    Code for the frame where the button is. Assuming the button has an instance name of my_btn.
    PHP Code:
    // when you click the button
    my_btn.onRelease = function()
    // if the sound is playing
    if (isPlaying)
    // stop it
    // start it

Tags for this Thread

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