A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: sound!

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    3

    sound!

    hi there,

    i'm trying to add sound to my game - when a coin is collected i need a it to make a sound.

    this is the actionscript i have used

    Code:
    onClipEvent (enterFrame) {
    
    if (this.hitTest(_root.fish)) {
    
    _root.score.text += 1;
    unloadMovie(this);
    
    }
    
    }
    thanks!

    claire

  2. #2
    Senior Member
    Join Date
    Dec 2009
    Posts
    109
    var snd = new Sound();
    snd.attachSound("coin_get.mp3");
    _root.snd.start(0,0);

    You need to export the sound for actionScript.

    Also, it would be a better idea to use arrays and put all of your code on the main timeline.
    Syntax Error

  3. #3
    President PhobiK's Avatar
    Join Date
    Jan 2005
    Location
    Guatemala
    Posts
    918
    The way Adam says is the way to go, but I think you should get rid of the "_root" in _root.snd.start(0,0), because you're declaring the variable locally. So applying it to your code it may be something like this:
    Code:
    onClipEvent(load) {
    var snd = new  Sound();
    }
    onClipEvent (enterFrame) {
    
    if (this.hitTest(_root.fish)) {
    snd.attachSound("coinSound");
    snd.start();
    _root.score.text += 1;
    unloadMovie(this);
    
    }
    
    }
    This is MC. His _parents sent him to stop() by the super market to buy some _root beer if he wanted to gotoAndPlay() with his friends at the park later.

    This is my Blog!... The gaming Process
    Please check out my site: Giddel Creations

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