A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: sound

  1. #1
    Member
    Join Date
    Sep 2005
    Posts
    45

    sound

    I am making a text adventure game. It's going pretty well so far, but I want to know what the code would be to use if I want to have a certain sound begin when someone types "look." I also want the sound to repeat many times until later when I tell it to stop.
    code:

    if (gRoom == "golfshop")
    {
    if (parseString == "look"){
    showText("You are in the golf shop.");
    cutscene.gotoAndPlay(1);
    stopAllSounds();
    // i'm guessing it goes here?
    return (true);}
    }



    Thanks in advance.
    Last edited by flashperson; 11-26-2005 at 01:25 PM. Reason: clarification

  2. #2
    FlashCLUE.com Wizzz's Avatar
    Join Date
    Nov 2005
    Location
    Warsaw Poland
    Posts
    451
    I'm not sure id\f I unerstand but r u asking for these besics:

    code:
    s = new Sound( this );
    s.attachSound('beep');
    s.start(0,1000000000);


    to start

    code:
    s.stop();
    delete s;


    to stop

    ?

  3. #3
    Member
    Join Date
    Sep 2005
    Posts
    45
    Thanks, but I couldn't get it to work. Let me clarify.
    In the library I have a sound clip that is a few minutes long called golf. If I want it to play and keep repeating like 100 times, what would I use? I tried
    code:

    golf.start(0,100);


    but it didn't work. Here is the whole statement:
    code:

    if (parseString.slice(0, 4) == "talk")
    {
    showText("Yes.");
    gRoom = "golf1";
    stopAllSounds();
    golf.start(0,100);
    return (true);}


  4. #4
    FlashCLUE.com Wizzz's Avatar
    Join Date
    Nov 2005
    Location
    Warsaw Poland
    Posts
    451
    Quote Originally Posted by flashperson
    sound clip
    hmmm what do u mean exactly? a movieclip with sound in a keyframe? if so use simply sound with linkage in library with my code

  5. #5
    smile for the camera! jesserules's Avatar
    Join Date
    Dec 2004
    Location
    a dark place where people have trouble in flash
    Posts
    720
    it should be golf.start(100, 0);
    My site
    The Current Project is RoboRace.
    Screens Public Beta Coming Soon!

  6. #6
    FlashCLUE.com Wizzz's Avatar
    Join Date
    Nov 2005
    Location
    Warsaw Poland
    Posts
    451
    Quote Originally Posted by jesserules
    it should be golf.start(100, 0);
    r u sure?
    Quote Originally Posted by FlashManual
    Sound.start
    Availability
    Flash Player 5.
    Usage
    mySound.start([secondOffset, loop])
    Parameters
    secondOffset An optional parameter that lets you start playing the sound at a specific point. For example, if you have a 30-second sound and want the sound to start playing in the middle, specify 15 for the secondOffset parameter. The sound is not delayed 15 seconds, but rather starts playing at the 15-second mark.

    loop An optional parameter allowing you to specify the number of times the sound should play consecutively.

  7. #7
    Member
    Join Date
    Sep 2005
    Posts
    45
    Thanks for your help, but I still can't get it to work. After more of the actionscript reference manual, I got this, but it still won't work. The file in my library is golf.mp3.
    code:

    var golf:Sound = new Sound('golf');
    golf.loadSound("golf.mp3", true);


    ^ under my variables, and here is where I want it to be activated:
    code:

    golf.start(0,100);


    Help would be very appreciated.

  8. #8
    skylogic.ca MD004's Avatar
    Join Date
    Oct 2003
    Location
    Canada
    Posts
    366
    When you create the sound on a movieclip: theSoundOb = new Sound(theMC);
    to play the sound you still use theSoundOb.start(); regardless of what the target MC is. The target MC is usually pointless so using '_root' or 'this' should do just fine.

    When you attach the sound file to theSoundOb like so: theSoundOb.attachSound("soundFile");
    "soundFile" is the name given in Library > right click on the file > Linkage Properties > check Export for Action Script

    Personally I always attach my sounds at the very beginning before the game starts:
    Code:
    explosion = new Sound();
    explosion.attachSound("explosionSnd");
    
    laser = new Sound();
    laser.attachSound("smallLaserSnd");
    and then i just use laser.start(0,0); or explosion.start(0,0); etc. and sometimes I use this: _root[aVariable].start(0,0); so that I can change aVariable whenever I want to, but that might not be necessary for you.

    Quote Originally Posted by flashperson
    golf.loadSound("golf.mp3", true);
    loadSound() loads an external sound, such as from a website, not from the library.

    Note: I use Flash MX but i'm pretty sure that these things wouldn't have changed much in other versions.

    ~MD

  9. #9
    FlashCLUE.com Wizzz's Avatar
    Join Date
    Nov 2005
    Location
    Warsaw Poland
    Posts
    451
    Quote Originally Posted by MD004
    "soundFile" is the name given in Library > right click on the file > Linkage Properties > check Export for Action Script
    thats the most important I feel this is flashpersons problem

  10. #10
    Member
    Join Date
    Sep 2005
    Posts
    45
    Thank you! I got it to work.

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