4 Replies Latest reply on Dec 16, 2006 12:24 PM by Newsgroup_User

    URGENT: AUDIO VIA KEY PRESS

    templecone
      hi,

      I am doing a project that requires me to trigger audio loops via keypresses.

      I'm assuming i should be running ASCII and then routing via key codes (aka Q=113)

      i do not know how to route the loops to different keys. Can anyone help me?
      please and thanks!
        • 1. Re: URGENT: AUDIO VIA KEY PRESS
          templecone Level 1
          i know it must be simple, all i want to do is control a certain audio file with a certain key.
          • 2. Re: URGENT: AUDIO VIA KEY PRESS
            templecone Level 1
            I think i am going to try this, but how do I "attach" this sound to a frame?



            dasaimedia wrote:
            > I am building a site for a client who wants to be able to press a keyboard
            > button such as the "up" button and have it play an instrument sound. I am
            > fimiliar with html and css coding but i am not that great at actionscript. It
            > would be greatly appreciated if someone could show me what I would have to do
            > to achieve this affect. I was looking around the web and saw something that
            > said I might need an eventlistner. I am com,pletely lost! All help welcome.
            > Thanks. Here is an example of exactly what I am trying to achieve, the only
            > difference is it doesnt need to be complicated and I only need it to work for 3
            > buttons. http://www.ababasoft.com/music/drums01.htm
            > http://www.kenbrashear.com/

            Many ways to achieves that. You can make a movie clip with (for 4 sounds) 5 frames.
            Frame 1 stop(); to prevent it from running. Frame 2 attach your sound, frame 3 another
            sound, frame 4 and 5 same. Give that movie clip instance name "soundCLIP" Now all you
            need is to add key listener to timeline frame so you can capture the key and go to
            corresponding frame of the movie clip to play your sound.

            var keyListObj:Object = new Object();
            keyListObj.onKeyDown = function() {
            switch (Key.getCode()) {
            case Key.LEFT :
            soundCLIP.gotoAndStop(2);
            break;
            case Key.UP :
            soundCLIP.gotoAndStop(3);
            break;
            case Key.RIGHT :
            soundCLIP.gotoAndStop(4);
            break;
            case Key.DOWN :
            soundCLIP.gotoAndStop(5);
            break;
            }
            };
            Key.addListener(keyListObj);





            • 4. Re: URGENT: AUDIO VIA KEY PRESS
              Level 7
              templecone,

              > http://pages.emerson.edu/students/m/michael_angelakos/polyphony.fla
              >
              > this my project. any suggestions?

              I suggest you start with the basics, take "baby steps," then progress as
              you go. For what you've described, it sounds like you'll need to consult
              the Key class and the Sound class in the ActionScript 2.0 Language
              Reference.

              >> I'm assuming i should be running ASCII and then routing
              >> via key codes (aka Q=113)

              Assumptions and programming often don't mix well. ;)

              > i know it must be simple, all i want to do is control a
              > certain audio file with a certain key.

              It's not simple unless you know how, right?

              > I think i am going to try this, but how do I "attach" this
              > sound to a frame?

              Since you're in the ActionScript forum, I'll point you toward the
              ActionScript answer. :) Sound objects are instantiated from the Sound
              class. The Sound class defines the properties, methods, and events
              available to any Sound instance, so that's a good place to start. Before
              you start combining audio with keystrokes, I recommend you take the time to
              experiment with the Sound class first. Master it a bit before heading over
              to the Key class, which gives you the other half of your equation.


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."