A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Audio actionscript problem (AS2)

  1. #1
    Senior Member
    Join Date
    Feb 2003
    Posts
    129

    Audio actionscript problem (AS2)

    Hello,

    I am using actionscript to play sounds in my game. Here is the code I'm using for a gun firing when the user clicks:

    Code:
    var beretta:Sound = new Sound();
    beretta.attachSound("gunshot");
    beretta.start(0, 0);
    That works fine. I also have a background sound that plays on a constant loop:


    Code:
    var tvstaticsound:Sound = new Sound();
     tvstaticsound.attachSound("tvsound");
     tvstaticsound.start (0, 999);
     tvstaticsound.setVolume(5);
    The above sound varies in volume depending on what room the player enters. I'm using the following code to alter the volume:

    Code:
    _root.tvstaticsound.setVolume(7);
    The problem I'm having is that when the actionscript alters the volume of tvstaticsound, the beretta sound also gets changed to the same volume. What am I doing wrong? Surely only the audio I've specified should have its volume changed?

    Thank you.

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    tie each sound to unique movieclip timelines to gain individual control
    Code:
    this.createEmptyMovieClip("gun",1000);
    var beretta:Sound = new Sound(gun);
    
    this.createEmptyMovieClip("tv",1050);
    var tvstaticsound:Sound = new Sound(tv);
    
    tvstaticsound.setVolume(7);
    Last edited by a_modified_dog; 05-11-2009 at 06:00 AM.

  3. #3
    Senior Member
    Join Date
    Feb 2003
    Posts
    129
    Thanks a lot, a_modified_dog. What does the number in ("tv",1050) determine?

  4. #4
    Ryan Thomson EvolveDesigns's Avatar
    Join Date
    Oct 2001
    Location
    British Columbia
    Posts
    3,338
    it's the level the mc is loaded in to so gun would be below tv.
    Evolve Designs Interactive Media
    the natural selection

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