A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: AS3 assign sound to keys

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    10

    AS3 assign sound to keys

    Iv created a virtual keyboard in flash using arrays and buttons i now want to assign a sound to all keys so that whenever they are pressed the sound will play, I'm guessing ill need to use a for loop or something but i really don't know how i would go around doing so. Please help, it is extremely urgent

  2. #2
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    That depends on how you named your sound files.

    If you named each sound the same as the keyCode of the key that it's assigned to then you can use getDefinitionByName to create the sound just by the keyCode of the key that is pressed.

    If you named the sounds differently than above, then you'll probably need an array of every sound and an array of every keyCode. When a key is pressed you find the index in the keyCode array of the pressed key then use that index to find the appropriate sound.

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    10
    Quote Originally Posted by 5Five555 View Post
    That depends on how you named your sound files.

    If you named each sound the same as the keyCode of the key that it's assigned to then you can use getDefinitionByName to create the sound just by the keyCode of the key that is pressed.

    If you named the sounds differently than above, then you'll probably need an array of every sound and an array of every keyCode. When a key is pressed you find the index in the keyCode array of the pressed key then use that index to find the appropriate sound.
    i dont have a sound yet but when i get one i just want that one sound to play every time a key is pressed. for example like the sound on the iphone keyboard when typing. how would one go about doing so

Tags for this Thread

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