This content has been marked as final. Show 6 replies
This would be a lot easier in just plain AS2.
Create a Key handler (read flash help on the Key Class). Add an event listener to the root timeline that checks button presses (specifically targeting the ascii value of the space bar) and when that occurs, tell your sound to start playing. If you want the space bar press to turn the music on and off you'll also need to set a boolean of some sort and test it based on whether the music is on or off. It should be a fairly simple routine to write after you read the Key class.
Ok this sorta worked but now it is doing what I was trying to work around before
Now it is playing both sounds at the same time when I press the button.
I have tried creating new clips, two buttons and disabling one, the Key handler makes good sense but maybe I am missing something.
Help anyone this is making me nuts
oh and btw snds is a variable loaded through an XML so its value changes as the flash parses the XML this all takes place in a single frame on the timeline through a setInterval controlled looping of data in a XML file.
The object here is if the user presses the spacebar in time they get a happy beep sound, but if they are too late they get a buzz sound.
I am pretty sure now that I understand what you are doing which raises questions as to why you are loading in an xml value since it isn't really necessary when you only have two sounds. Based on the info you've provided, I believe tour timer function needs one more little line that sets a boolean value to true when the right time is met and to false when it is not. Then you can do this....
ok that helped, I also added one extra line with stopAllSounds before it starts the sound. This fixed another instance where it was overlapping a bit.
To answer your query I am loading more than sound values through the XML
the entire movie is generated by getting values each pass around a loop to move various objects and display them at variouos locations the sound value just happens to be one of the attributes of each node that is passing through. Iwas easier to do it this way since there are 100 instances of the objects that need to be displayed before the end of the movie.
Thanks for the Help
Ahh ok. Well I'm glad I could help.