SpaceShooter Game
How to Control All Sounds
That is to control the global sounds in Action Script 3.0. SoundMixer class allows you to control all sounds in your SWF. SoundMixer has soundTrandsform property, which must be specified in a way something like this:
But firstly, you might have to load a sound file.
var snd:Sound = new Sound(new URLRequest(“bigSound.mp3″));
var trans:SoundTransform = new SoundTransform(0.6, -1);
var channel:SoundChannel = snd.play(0, 1, trans);
SoundMixer.soundTransform = trans;
Why do we need SoundChannel here? Well, we don’t need it, actually. But we need it, if we wish to stop() the sound later, because, you can’t stop a playing sound by referring directly.
For example: snd.stop(); will not work.
You need to refer to channel.stop();
How to Check Which Side Has Collided
ActionScript does not have such a built-in method to handle such complex collision detections. As a matter of fact, this is not so complicated at all. All you have to do is to check if the colliding objects are placed in one “row” to check side collisions and check if they are in one “column” to check for top or bottom collisions. You can check if it is the left side or right by checking the x positions of the objects.


Check Client System Capabilities
The ActionScript 3.0 programming.
Use the Capabilities class to detect the environment in which the SWF file is running. The properties of the Capabilities class allow you to find out the resolution of the user’s screen, whether the user’s system supports accessibility software, the language of the operating system, and also the version of the currently installed Flash Player. There are many reasons why you would want to do this. One of this is to customize your application to work best with the user’s system environment. For example, by checking the Capabilities.screenResolutionX and Capabilities.screenResolutionY, you can decide which video size would be the most appropriate. Capabilities.hasMP3 property allows you to see if the user’s system supports mp3 files. You do not want to load a file that can’t play anyway. So here is the code snippet that demonstrates the above mentioned and more properties of Capabilities class. In order to use it, just copy and paste the code into the Action window of your Adobe Flash application and hit Ctrl+Enter to test. Good luck.
var versionString:String = Capabilities.version;
var pattern:RegExp = /^(\w*) (\d*),(\d*),(\d*),(\d*)$/;
var result:Object = pattern.exec(versionString);
if (result != null)
{
trace(“input: ” + result.input);
trace(“platform: ” + result[1]);
trace(“majorVersion: ” + result[2]);
trace(“minorVersion: ” + result[3]);
trace(“buildNumber: ” + result[4]);
trace(“internalBuildNumber: ” + result[5]);
}
else
{
trace(“Unable to match RegExp.”);
}
