A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Sound help

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    24

    Sound help

    How do I make my money object Make a sound when I pick it up? I got the scoring and everything good, I just need my money to make a sound when I pick it up, How would I do this?

    I am in flash 8 please help me.

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    What's the code for picking up money? If it's something like this:

    Actionscript Code:
    onClipEvent(enterFrame){
         if(this.hitTest(_root.player)){
              unloadMovie(this);
         }
    }

    then import your sound file into Flash, in the Library, find it there (CTRL+L), right-click it, press Linkage, in the Identifier field, type in, coinSound, and press OK. Use this code after, unloadMovie(this); :

    Actionscript Code:
    sound = new Sound();
    sound.attachSound("coinSound");
    sound.start(0, 1);

    making the whole code look something like this:


    Actionscript Code:
    onClipEvent(enterFrame){
         if(this.hitTest(_root.player)){
              unloadMovie(this);
              sound = new Sound();
              sound.attachSound("coinSound");
              sound.start(0, 1);
         }
    }

    and btw, always include codes you use in your posts, otherwise people won't be able to help you, because there are multiple ways of coding one thing, and it varies from programmer to programmer
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Junior Member
    Join Date
    Feb 2012
    Posts
    24
    Quote Originally Posted by Nig 13 View Post
    What's the code for picking up money? If it's something like this:

    Actionscript Code:
    onClipEvent(enterFrame){
         if(this.hitTest(_root.player)){
              unloadMovie(this);
         }
    }

    then import your sound file into Flash, in the Library, find it there (CTRL+L), right-click it, press Linkage, in the Identifier field, type in, coinSound, and press OK. Use this code after, unloadMovie(this); :

    Actionscript Code:
    sound = new Sound();
    sound.attachSound("coinSound");
    sound.start(0, 1);

    making the whole code look something like this:


    Actionscript Code:
    onClipEvent(enterFrame){
         if(this.hitTest(_root.player)){
              unloadMovie(this);
              sound = new Sound();
              sound.attachSound("coinSound");
              sound.start(0, 1);
         }
    }

    and btw, always include codes you use in your posts, otherwise people won't be able to help you, because there are multiple ways of coding one thing, and it varies from programmer to programmer
    my code for picking up money is

    onClipEvent(enterFrame) {
    if(_root.char.hitTest(this)) {
    _root.money += 10;
    unloadMovie(this);
    }
    }

  4. #4
    Junior Member
    Join Date
    Feb 2012
    Posts
    24

    Talking

    Quote Originally Posted by nig 13 View Post
    what's the code for picking up money? If it's something like this:

    actionscript Code:
    onclipevent(enterframe){
         if(this.hittest(_root.player)){
              unloadmovie(this);
         }
    }

    then import your sound file into flash, in the library, find it there (ctrl+l), right-click it, press linkage, in the identifier field, type in, coinsound, and press ok. Use this code after, unloadmovie(this); :

    actionscript Code:
    sound = new sound();
    sound.attachsound("coinsound");
    sound.start(0, 1);

    making the whole code look something like this:


    actionscript Code:
    onclipevent(enterframe){
         if(this.hittest(_root.player)){
              unloadmovie(this);
              sound = new sound();
              sound.attachsound("coinsound");
              sound.start(0, 1);
         }
    }

    and btw, always include codes you use in your posts, otherwise people won't be able to help you, because there are multiple ways of coding one thing, and it varies from programmer to programmer
    nig you helpful sunnova*****!!! :d

  5. #5
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    That's almost the same as the one I anticipated, so you should be able to modify it by yourself, but if not, then here you go:

    Actionscript Code:
    onClipEvent(enterFrame){
         if(_root.char.hitTest(this)){
             _root.money += 10;
              unloadMovie(this);
              sound = new Sound();
              sound.attachSound("coinSound");
              sound.start(0, 1);
         }
    }

    then follow what I said in my previous post about linking a new sound from the Library
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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