Arcade Prehacks

Results 1 to 8 of 8
  1. #1
    Administrator selectLOL's Avatar
    Join Date
    May 2010
    Posts
    3,290

    As2: sound and backgroundmusic

    In this short tutorial i will show you how play music files in as2.
    What do we need:
    • 2 music files. One of them is a music and the other a sound effect.
    • General knowlegde about as2 and flash.


    At first import the 2 files in the library. Then select the music and right click > properties/attributes (ok, i have the german version, so i dont know what there is in the englisch version. Its the last item) > Check "Export for actionscript. Then give it the name "my_music". Do the same with the sound and give it the namy "my_sound".

    Now you need some actionscript. We have to attach these 2 files to variables. We create a new sound:
    Code:
    _root.my_music = new Sound(_level0)
    _root.my_sound = new Sound(_level0)
    We will need following founction: attachSound( - name - )
    Now we attach the files:
    Code:
    _root.my_music.attachSound("my_music")
    _root.my_sound.attachSound("my_sound")
    Now we have to start the music. We use the function: start( - secondOffset - , - loop)
    Code:
    _root.my_music.start(0,9999999) // this will play it in a endless loop
    _root.my_sound.start(0,1) //this will play it one time
    To stop use stop()
    Code:
    _root.my_music.stop()
    _root.my_sound.stop()

    Now we want to make a mute function. You can call this function with a button, key or context menu item.

    We have a music and sound. We give the opinion to mute the music or sound. At first we need 2 controll variables.
    Code:
    _root.mute_music = false
    _root.mute_sound= false
    To mute we will set the volume to 0. But we have to make the function first.
    Code:
    function mute(mode){
      if (mode == "music"){
        if(_root.mute_music == false){
          _root.mute_music = true
          _root.my_music.setVolume(0)
        }else{
          _root.mute_music = false
          _root.my_music.setVolume(100)
        }
      }else if (mode == "sound"){
        if(_root.mute_sound == false){
          _root.mute_sound = true
          _root.my_sound.setVolume(0)
        }else{
          _root.mute_sound = false
          _root.my_sound.setVolume(100)
        }
      }else{
        trace("Parameter is not valid!")
      }
    }
    This function has one parameter. It mutes and unmutes. If you input a wrong paramter, it traces a small text on the debug console.

    Hope you learned something from this tutorial. Make sure you read my other tutorials.
    My website: http://selectlol.com/
    My second game: Play it now

    Its easier to find intelligent life in the universum than in the internet.

  2. #2
    Senior Member
    Join Date
    Jul 2009
    Posts
    8,079

    Re: As2: sound and backgroundmusic

    How could i rip sound from an existing game?

  3. #3
    Administrator selectLOL's Avatar
    Join Date
    May 2010
    Posts
    3,290

    Re: As2: sound and backgroundmusic

    You can rip it with sothink from a flash game. I dont know how to rip sounds from other files.
    My website: http://selectlol.com/
    My second game: Play it now

    Its easier to find intelligent life in the universum than in the internet.

  4. #4
    Senior Member
    Join Date
    Feb 2010
    Location
    http://tinyurl.com/2atap49
    Posts
    2,328

    Re: As2: sound and backgroundmusic

    You could use an Audio extractor.
    I have an installer for one:
    http://www.mediafire.com/?96c3x499wsc2ec7
    Virus scan: http://www.virustotal.com/file-scan/rep ... 1294242209
    Um... I used to be a moderator here...

  5. #5
    Senior Member
    Join Date
    Jan 2010
    Location
    TRMI
    Posts
    4,616

    Re: As2: sound and backgroundmusic

    you forgot the virus scan report

  6. #6
    Senior Member
    Join Date
    Feb 2010
    Location
    http://tinyurl.com/2atap49
    Posts
    2,328

    Re: As2: sound and backgroundmusic

    Quote Originally Posted by Deathnote202
    you forgot the virus scan report
    Sorry, fixed
    Wow, new rule and I'm already breaking it, lol
    Um... I used to be a moderator here...

  7. #7
    Senior Member
    Join Date
    Nov 2010
    Location
    6C 69 6E 6B F6 70 69 6E 67 2C 20 73 77 65 64 65 6E
    Posts
    590

    Re: As2: sound and backgroundmusic

    The mediafire link to the audio extractor isn't working.

  8. #8
    Senior Member
    Join Date
    Feb 2010
    Location
    http://tinyurl.com/2atap49
    Posts
    2,328

    Re: As2: sound and backgroundmusic

    Quote Originally Posted by superdragonfruit
    The mediafire link to the audio extractor isn't working.
    Sorry, I was cleaning out my Mediafire account and I guess I removed it.
    Fixed.
    Um... I used to be a moderator here...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •