So You Think You’ve Finished Mixing? A Guide to Preparing Your Mix for Mastering

You know what it feels like to finish a mix. Having spent hours, possibly days, perfecting your track to the nth degree, it feels great to finally have a song to be proud of after all the hard work and effort.

But what if you took your mix just that little bit further. Before the crucial mastering stage, there are some very simple, and often overlooked, practices and techniques which can be applied to your mix in order to make sure your track stands out from the crowd and better yet, your final master is as good as it possibly can be.


Step 1: Check Your Levels

Once you’ve finished your mix the first place to start is to take a look at the levels on your master bus. (Technically, you should be monitoring this all throughout the mix but we’ll assume that hasn’t happened). All major DAWs contain a basic meter on the master bus channel. Reset your meter and do a whole pass of the track to check exactly where your song peaks (i.e., where the level reaches it’s highest point during the pass). Typical mastering engineers want roughly 3 dBs of headroom on the mix to give themselves the most flexibility – this is especially true if you are working in 16bit rather than 24bit.

If you find yourself with excessive levels on the master bus (or even clipping) there are a couple of options to try. If you have maintained respectable levels on each individual channel, lower the overall level by simply reducing the master fader a few dBs as appropriate, ensuring the integrity of your mix stays intact. However you may only be temporarily fixing problems that lie deeper in your mix session.

If you find that individual channel levels are to blame, it’s probably a better idea to reduce channel levels equally and individually so by the time the audio reaches the master bus there are no level issues – i.e., you’ve reached an acceptable master bus level completely naturally. Remember to maintain respect with any particular routing you have used – e.g., don’t reduce a bus as well as your respective channels as this will throw the balance out.

If the levels still look unusually active, delve a little deeper and check if any individual plugins are clipping. If a plugin has been set to force hot levels out to your DAW, there’s a good chance clipping will occur. (Some analogue clipping can sound great, but digital plugin clipping is the total opposite – you really don’t want this on your mix!) Most plugins have an input/output level trim so if a channel looks to be overworking itself, check the inserts for any clipping and adjust accordingly.

A channel may clip and affect your master bus level if an Insert is forced to process to an extreme. Above, the “In” meter shows the input channel level is acceptable, however when the EQ plugin kicks in you can clearly see the level clipping upon outputting.

To demonstrate just how easy it is to accidentally clip a channel, here is an example of a quiet synth part meant to “pad” out a song. This kind of part can easily get lost in a mix, as that’s the parts purpose:

Download audio file (synth.mp3)

As you can hear, it sounds totally fine. However, it’s very easy to accidentally clip something which is quiet in the mix, particularly if it’s been recorded hot. Here’s the same synth part, but with an inserted EQ plugin with a clipped output:

Download audio file (synthclipped.mp3)


Step 2: Check the Inserts on the Mix Bus

There is a lot of healthy debate over the dos and don’ts of inserting effects onto the mix bus. It’s quite easy to overload the bus to help the track shine (especially if you’re doing quick mixes to send to a band for approval, for example) but be very careful of wandering into the mastering engineer’s domain.

Some mixers feel they need to limit the creative control of the mastering engineer by overly processing the master bus (perhaps with mastering-style EQ or limiting) and this is sometimes for a perfectly rational reason, especially if a top-line reputation is involved.

Regardless, I would never recommend adding a limiter to your mix bus. Quite often, digital limiters don’t offer the same sonic finesse of analogue limiters used by most mastering engineers (particularly in the higher frequency spectrum) and you’ll be depriving a mastering engineer of an essential part of their job. Let them do what you’ve hired them to do.

That said, it’s very common to subtly process your master bus – generally this is to help “glue” your mix and add a little sparkle and consistency. One common approach is to gently process a mix through the classic SSL bus compressor to give your mix extra unity and to utilise its iconic individual “sound”.

By all means, experiment and have a play around with your master bus but make sure you use inserts with caution. Always question why you’re adding an insert to the bus – if you have any doubt, you probably shouldn’t do it!


Step 3: Don’t Dither!

I’ve already mentioned how careful you need to be when adding inserts onto the master bus – however if you do decide to add a little “fairy dust” to your mix then be aware that some plugins could apply a dither algorithm. The plugin should have an option to turn this off, so make sure that dither is always switched off unless you are reducing your bit rate on mix-down.

If you’ve recorded at 24bit I would recommend bouncing your mix at this bit depth ready for the mastering engineer and not to worry about the dithering process. Dithering is a vital part of mastering but let your mastering engineer apply this at the final hurdle and certainly don’t do it for him during the mix bounce.


Step 4: Check Your Mix in Mono

If there’s one process for you to try it’s this one. Checking your mix in mono is vital and truly under-valued – there are countless reasons why your mix may end up being heard in mono.

If your song is broadcast on the radio, often it will be in mono if the signal is particularly weak. Even advanced technology still utilises mono signals – most radio iPhone applications broadcast in mono, unbelievably! When listening in mono, your track could run into major phases issues when processing reverb or delay and sometimes the effect can be totally lost.

To demonstrate, here is a guitar part with a delay effect in stereo:

Download audio file (guitarstereo.mp3)

And here is the exact same part, heard now in mono:

Download audio file (guitarmono.mp3)

As you can hear, the delay effect has been completely destroyed on the second example. Would you be happy with the mono sonic representation? Obviously there will have to be a degree of compromise but this will naturally vary mix to mix, especially if the effect is essential to your “mix vision”.

The TT Dynamic Range Meter is a great free plugin which monitors the dynamic range of your master bus. In addition, it can process a mix in mono. Simply place the meter on your master bus and click the mono button. (You can download the TT Dynamic Range Meter for free at http://www.brainworx-music.de/en/downloadrequest).

Above all, it’s essential to make sure your mix translates throughout multiple scenarios so spend time making sure your mix works as best as possible in mono – you never know who could be listening!

The free TT Dynamic Range Meter is a great way to visually check the dynamic range of the mix and includes a handy mono button at the bottom.


Step 5: Check Your Imported Samples

Have you imported any samples into your project? Most DAWs can cope with audio files of multiple bit depths, as they will usually be converted during the import process. (If not, make sure they are!) However it’s useful to check the bit depths of your imported samples in advance. It is common practice to record and mix at 24bit but sometimes you may find you want to use samples at 16bit – however this doesn’t mean you shouldn’t use them.

It’s important to note that converting a 16bit sample to 24bit will not make the initial sample any better in quality, however it ensures that any processing or plugins you use on the 16bit sample are operating at 24bit, which will give a higher fidelity value to the sound, post-processing.

Above is an example of the Pro Tools “Import Audio” function. Here, a snare sample is at 16bit 44,100Hz whereas the project is operating at 24bit 48,000Hz. As a result, Pro Tools will convert the audio to match the project sample rate and apply all further processing to the snare sample at 24bit 48,000Hz.


Step 6: Don’t Get Caught Short!

Imagine this. You’ve secured your first major mix job with a major label. You’ve worked until the early hours for days on end polishing the mix. Eventually, it’s submitted, you’re paid, deadline achieved! Two weeks later you get a late night call from the label, “We need a new radio edit with a more upfront vocal. It needs to go to the radio plugger tomorrow.”

A good mix engineer is always aware a mix recall may need to happen – so make sure you’re not caught short and you’re well equipped to deal with the scenario. Print the audio of any plugins you’re thinking of uninstalling. Did you use any outboard gear? If so, get a print of it just in case. Perhaps take a picture of the settings. Upgrading your OS? Will your plugins still work?

Make sure you’ve got the means to cope with any recalls that need to happen. Generally though, once something is released you’ll not need to worry!


Step 7: Some Final Advice

Here are some quick tips that really can make all the difference:

  • Rest your ears! You will find that sleeping on a mix after a hard days work will often open your ears up and give you a fresh perspective. If possible, it’s always worth revisiting a mix the next day before you really do call it ‘finished’!
  • Check your export marker points! It seems obvious but it’s a common mistake. Don’t start the export the precise moment the song kicks in. Give the mastering engineer a few seconds to manoeuvre. The same applies to the ending. Unless it’s for creative reasons, make sure you export to the very end of your track – double check any overhanging effects!
  • Get to know your mastering engineer! It’s always great to get a working relationship going. Send them the song in advance and if possible, get their opinion on the mix. Any mastering engineer worth their salt will always hear your mix with the master in mind and may be able to point out where you could improve your mix in order to get the best out of the mastering session.

Conclusion

Reading this tutorial you’ll have noticed the emphasis placed on respecting the mastering process. It’s often overlooked in our ambition to make mixes sound as professional as possible from the offset.

If there is anything to take away from reading this tutorial it’s that you should always mix with the mastering engineer in mind. Remember, if you’re beginning to question any of the finishing touches you’re adding then you’re almost certainly in the mastering engineers territory. However, if you have a vision or direction for your mix then this must be incorporated at the mix stage; no matter how good a mastering engineer might be, he can’t fix your mix.

And as luck would have it, that’s our job!


Create a Realistic Energy Drink Can to Present to Clients – Psd Premium Tutorial


Today, we have another Psd Premium tutorial exclusively available to Premium members. If you want to take your package design skills to the next level, then we have an awesome tutorial for you. Learn more after the jump!


This Premium Tutorial is Filled with Creative Tips

We have all been there before; how can we make our artwork look great when we are presenting to clients? The single easiest way to show something to a client is to show them in a way that they can understand. This tutorial will show you how to create a realistic energy drink in a way that you can demonstrate to your clients. Lets get started!


Professional and Detailed Instructions Inside

Premium members can Log in and Download! Otherwise, Join Now! Below are some sample images from this tutorial.


Psd Premium Membership

As you know, we run a premium membership system here that costs $9 a month (or $22 for 3 months!) which gives members access to the Source files for tutorials as well as periodic extra tutorials, like this one! You’ll also get access to Net Premium and Vector Premium, too. If you’re a Premium member, you can log in and download the tutorial. If you’re not a member, you can of course join today!

Deploy a Tank on a Mission in an Isometric War Zone

In this lesson we’re going to create a little tank moving application. The core of this particular tutorial is to make a tank aim at the the mouse pointer and drive towards a mouse click.


Final Result Preview

Let’s take a look at the final result we will be working towards:

Move the mouse to make the turret aim at it, and click anywhere to get the tank to drive to that point.

Step 1: Graphics Intro

Well, let’s get started.. For this tutorial we’ll need tank and turret graphics. I used Google SketchUp 7 to make mine.

First I created a tank as a whole. Then I turned the program’s view mode to “parallel projection”, positioning my camera at a 45° angle to the tank to make an illusion of isometrics in the game.

Please, don’t judge me for horrible graphics, I really can do much better but this is just for the sake of explanation :)

Then I hid the turret leaving only the tank body visible and rotated the body by 45° eight times, rendering each position separately. So I achieved 8 different views of the body. I did the same thing to the turret while the tank was hidden. I saved all 16 pics as PNG 24 with alpha channel. You can see the final result below. (This is not actually enough for this kind of movement, it would be better to have twice as many views of the tank but it’s enough for the purposes of this tutorial.)

.

You don’t necessarily need to use Google SketchUp of course, you may wanna use 3ds max or Maya or whatever you like, you may also use my graphics to practice if you don’t want to or cannot create your own graphics.

Step 2: New Flash Project

Now open up Flash (I use Adobe Flash CS4) and choose Create New Flash File (Actionscript 3.0). We will only need it to make a tank MovieClip and to connect the Game class to it later.

.

Step 3: Set the Document Properties

Right-click the stage and go to the Document Properties item. Make it 600 x 400 (or whatever you like) and 21 frames per second (this frame rate seems to be optimal to me so I almost always use it. It doesn’t really matter, though).

Click OK. Go to File > Save as and save this file as tank.fla in some folder on your computer (I recommend you create a Tank folder and put the file inside).

Step 4: Import Your Tank Images to Library

Now go to File > Import > Import to library. Find the folder where you saved your eight tank images, select them all and import to library.

.

Step 5: New Symbol

Create a new empty symbol by clicking this little icon in the library:

Choose MovieClip type and call the symbol “tank”. Put the registration point in the center (the registration point is that tiny black square in that grid of white squares, for those who don’t know).

Step 6: Edit the Symbol

After the symbol is created it appears in the library (its name “tank” is just a cosmetic name which is used solely in the library so it doesn’t matter what you call it). Open it by double-clicking its icon. Then take 1.png from the library and drag it onto the symbol’s stage. Align the image to the symbol’s registration point like in this screenshot:

You want the registration point to be in the center of the tank’s turning circle.

Step 7: Create Seven Blank Key Frames

Go to the symbol’s timeline. Rename the “Layer 1″ to “Tank”. Your tank’s body image (1.png) should be on the first frame of this layer. Click the second frame and without releasing your mouse button drag the cursor to the 8th frame selecting frames 2 through 8. Then right-click this selected area and choose “Convert to blank keyframes”.

Step 8: Drag All Images Onto the Stage

When 7 blank key frames are created, select the second frame and drag 2.png to it aligning the image with the registration point (just like you did with 1.png); imagining that the registration point is an axis that the tank will use to spin around when it’s turning. Do the same to the rest of the frames. You don’t have to align it very precisely, but the more precisely you align it the better the movement will look when the tank tries to follow the cursor as the game runs.

Step 9: Prevent the Timeline from Playing

After you dragged every image to the symbol’s stage and aligned them select the first frame and push F9 to open the actions panel. Type a single method “stop();” in it and close the panel. This is an important step because we don’t want our tank to automatically start spinning around as soon as it’s added to the stage.

Step 10: Create a Turret MovieClip

Go to the library and create a new MovieClip symbol. Call it turret. Double-click the symbol’s icon and do the same you did with the tank MovieClip (Steps 4 through 8) to the turret but using turret images. Align it to the registration point this way, at the point around which the turret would naturally turn:

Notice that I’ve named the turret images like this: 1-.png, 2-.png and so on, so that they wouldn’t replace the tank images when imported to library. You may want to use folders to put your images into. In this case your turret and tank images may have the same names.

Step 11: Assembling the Tank

After we’ve finished with turret symbol, open up the tank symbol again, create a new layer above the “Tank” layer and drag the turret movie clip from the library onto this layer. Align the turret with the tank body. The result should look like this:

Step 12: Give the Turret an Instance Name

Click once on the turret to select it (blue rectangle around it will indicate that it’s selected):

…then go to properties and give it and instance name mTurret (for MovieClip turret):

Click “Scene 1″ link to exit symbol editing mode.

Step 13: Export Your Tank for ActionScript

Right-click the tank symbol in the library, choose Properties (or Linkage if you’re using Flash CS3) from the dropdown menu (make sure you’re in an Advanced mode), check “Export for Actionscript”, and for the class’ name type in “Tank” (with capital T). This step will allow us to connect our Tank MovieClip to the instances created using our Tank class in future.

The graphics part is over for now; you may delete the tank from the stage. We’ll add it programmatically later.

Step 14: Create a New ActionScript File

In your Flash Authoring tool go to File > New and create a new ActionScript file.

Step 15: Save Your File

Go to the folder where you saved your tank.fla file and create a new folder called “main” inside. Save your ActionScript file in this folder as TankMaker.as. The location of this file should therefore be: tank/main/TankMaker.as

Step 16: Let’s Write Some Code

First of all, create a package and import the necessary classes into it:


package main {	

	import flash.display.*;
	import flash.events.*;

}

The word “main” here means the location of this file relative to our tank.fla

We will need “display” classes to show our assets on the screen and “events” to keep track of the mouse events.

Step 17: Public Class and Variables

Now we have to declare a public class TankMaker (according to the Actionscript file’s name) and the necessary variables:

package main {

	import flash.display.*;
	import flash.events.*;

	public class TankMaker extends Sprite {

		// the instance of our Tank class (which we exported for actionscript before)
		private var tank:Tank;

		// the vars to keep the coordinates of the point where we want our tank to move
		private var moveTankToX:Number;
		private var moveTankToY:Number;

		// coordinates of the point at which the tank aims its turret
		private var turnTurretToX:Number;
		private var turnTurretToY:Number;

		// current position of the tank
		private var currentTankPositionX:Number;
		private var currentTankPositionY:Number;

		private var tankSpeed:Number = 2;

		// the point at which the tank moves after a mouse click
		private var clickPoint:Object;

		// the angle of tank and turret rotation in radians
		private var Atan2:Number;
		private var turretAtan2:Number;
	}
}

I declared all of the variables as “private” because I don’t want them to be accessible from anywhere outside this class.

Step 18: Create a Constructor Method

Directly below the last variable create a public function and call it TankMaker. It’s going to be the constructor of the class. Then add an event listener for Event.ADDED_TO_STAGE to it so that we can create our tank object only after the stage is. Then pass this event to the method called addStage.

public function TankMaker() {

	addEventListener(Event.ADDED_TO_STAGE, addStage);

}

Step 19: Create a Tank Instance

After the stage is created and the ADDED_TO_STAGE event has triggered the addStage() method it’s about time to create a tank instance.

Declare a private function and call it addStage. The data type of the function will be: Event. And the return type will be “void” because we’re not going to return anything from it.

private function addStage (e:Event):void {

	//create a new tank instance of the movie clip
	// which you had exported for actionscript
	tank = new Tank();

	// now a little trick, I scaled my tank down
	// to the size of about one fourth of its original size
	// so that is wasn't so huge
	tank.scaleX = 0.25;
	tank.scaleY = 0.25;

	// set the initial position of the tank right
	// in the center of the stage
	tank.x = stage.stageWidth / 2;
	tank.y = stage.stageHeight / 2;
	// and add it to the display list
	addChild(tank);

	// now add event listeners for mouse down and mouse move
	// events to the stage
	stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
	stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveListener);

}

Step 20: Handling Mouse Movements

Create a private function mouseMoveListener() with a data type of mouse event to handle mouse movements across the stage. The event listener to trigger this function was created in the last Step.

private function mouseMoveListener(e:MouseEvent):void {

	// create a variable to keep the relative angle
	// between mouse's current position in degrees
	// and the tank's current position
	var angle:Number;

	// the next 2 variables are gonna be
	// equal to the the mouse's current position
	turnTurretToX = e.stageX;
	turnTurretToY = e.stageY;

	// calculate the relative angle in radians
	// between the mouse's curent position
	// and the tank's current position

	turretAtan2 = Math.atan2(turnTurretToY - currentTankPositionY, turnTurretToX - currentTankPositionX);

	// calculate the same angle in degrees.
	// to get degrees out of radians we have to
	// multiply radians by 180 and divide the result by PI
	// But here are some specifics of Flash
	// it calculates the angle not from 0 thru 360
	// but from 0 thru 180 and from - 180 thru 0

	// so let's add some conditional to get rid of this problem
	if (Math.round(turretAtan2 * 180 / Math.PI) < 0) {
		// if angle is between 0 and -180 add 360 to it
		angle = Math.round(turretAtan2 * 180 / Math.PI) + 360;
	} else {
		// if not, calculate it as usual
		angle = Math.round(turretAtan2 * 180 / Math.PI);
	}

	// having our angle value stored in a variable
	// let's rotate our turret towards the mouse pointer

	// I've done a lot of calculations trying to
	// figure it all out, so you may try to undestand my logic

	// I'm just picking the right frame of the turret MC depending
	// on the angle of the mouse from the turret

	if (angle > 240 && angle < 300) {
		// go inside the tank MovieClip then inside mTurret
		// go to the frame 1 and stop
		tank.mTurret.gotoAndStop(1);
	}
	if (angle > 300 && angle < 340) {
		tank.mTurret.gotoAndStop(2);
	}
	if ((angle >= 0 && angle < 20) || (angle > 340 && angle <= 360)) {
		tank.mTurret.gotoAndStop(3);
	}
	if (angle > 20 && angle < 60) {
		tank.mTurret.gotoAndStop(4);
	}
	if (angle > 60 && angle < 120) {
		tank.mTurret.gotoAndStop(5);
	}
	if (angle > 120 && angle < 160) {
		tank.mTurret.gotoAndStop(6);
	}
	if (angle > 160 && angle < 200) {
		tank.mTurret.gotoAndStop(7);;
	}
	if (angle > 200 && angle < 240) {
		tank.mTurret.gotoAndStop(8);
	} // end

}

Step 21: Mouse Click Handler

Below the end of our mouseMoveListener() function create a private function called mouseDownListener() with data type of MouseEvent and pass it to the moveTankOnEnterFrame method:

private function mouseDownListener(e:MouseEvent):void {

	// when click occurs assign the next variable
	// the coordinates of the mouse pointer's current position
	moveTankToX = e.stageX;
	moveTankToY = e.stageY;
	// and add event listener to move the tank frame by frame
	addEventListener(Event.ENTER_FRAME, moveTankOnEnterFrame);

}

Step 22: Move Tank Frame By Frame

Create a new private function called moveTankOnEnterFrame() and inside it call a method moveToCoordinates() with 3 parameters:

private function moveTankOnEnterFrame(e:Event) {
	moveToCoordinates(tank, moveTankToX, moveTankToY);
}

This will, eventually, cause the tank to drive towards the clicked point, every frame.

Step 23: Teach the Tank To Move

Now we have called moveToCoordinates() method but we haven’t created it yet. Let’s do that now.

The tX and tY won’t be used but we must create as many parameters as we called. This is how it looks:

private function moveToCoordinates(tank_mc:Tank, tX:Number, tY:Number) {

	// create a variable to keep the relative angle
	// between mouse's current position in degrees
	// and the tank's current position
	// this variable exists only inside this function so
	// you we can use the same name as we used before
	var angle:Number; 

	// calculate the angle (remember moveMouseListener?
	// we do the same here but with the tank itself)
	if (Math.round(Atan2 * 180 / Math.PI) < 0) {
		angle = Math.round(Atan2 * 180 / Math.PI) + 360;
	} else {
		angle = Math.round(Atan2 * 180 / Math.PI);
	}

	if (angle > 240 && angle < 300) {
		tank.gotoAndStop(1);
	}
	if (angle > 300 && angle < 340) {
		tank.gotoAndStop(2);
	}
	if ((angle >= 0 && angle < 20) || (angle > 340 && angle <= 360)) {
		tank.gotoAndStop(3);
	}
	if (angle > 20 && angle < 60) {
		tank.gotoAndStop(4);
	}
	if (angle > 60 && angle < 120) {
		tank.gotoAndStop(5);
	}
	if (angle > 120 && angle < 160) {
		tank.gotoAndStop(6);
	}
	if (angle > 160 && angle < 200) {
		tank.gotoAndStop(7);
	}
	if (angle > 200 && angle < 240) {
		tank.gotoAndStop(8);
	}

	// give the clickPoint a value of a current mouse position
	// when a click occurs
	clickPoint = {x:moveTankToX, y:moveTankToY};

	// calculate the angle in radians between the pointer's
	// current position and tank
	Atan2 = Math.atan2(clickPoint.y - tank_mc.y, clickPoint.x - tank_mc.x);

	// now add a value of Atan2 cosine to the tank's X position
	// and sine to its Y position every frame
	tank_mc.x += Math.cos(Atan2) * tankSpeed;
	tank_mc.y += Math.sin(Atan2) * tankSpeed;

	// now give the values to currentTankPositionX and
	// currentTankPositionY which we used in our mouseMoveListener
	currentTankPositionX = tank_mc.x;
	currentTankPositionY = tank_mc.y;

	// and finally a little trick. Since we don't want our tank to
	// start chaotically vibrating when it reaches its destination
	// we must calculate the distance between the tank's position and
	// the click point, and if it's less than 15, remove the ENTER_FRAME listener
	if (Math.abs(tank_mc.x - clickPoint.x) < 15 && Math.abs(tank_mc.y - clickPoint.y) < 15) {
		removeEventListener(Event.ENTER_FRAME,moveTankOnEnterFrame);
	}
}

Why use a distance of 15? Well, I found out that it never goes beyond 15 by simply tracing it like this:

trace(Math.abs(tank_mc.x - clickPoint.x));

…you can do the same if you want ;)

Step 24: Overviewing The Whole Class

As our class is ready, let’s take a look at it as a whole:

package main {

	import flash.display.*;
	import flash.events.*;

	public class TankMaker extends Sprite {

		private var tank:Tank;

		private var moveTankToX:Number;
		private var moveTankToY:Number;

		private var turnTurretToX:Number;
		private var turnTurretToY:Number;
		private var currentTankPositionX:Number;
		private var currentTankPositionY:Number;

		private var tankSpeed:Number = 2;

		private var clickPoint:Object;

		private var Atan2:Number;
		private var turretAtan2:Number;

		public function TankMaker() {

			addEventListener(Event.ADDED_TO_STAGE, addStage);

		}

		private function addStage (e:Event):void {

			tank = new Tank();
			tank.scaleX = 0.25;
			tank.scaleY = 0.25;
			tank.x = stage.stageWidth / 2;
			tank.y = stage.stageHeight / 2;
			addChild(tank);

			stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveListener);

		}

		private function mouseMoveListener(e:MouseEvent):void {

			var angle:Number;

			turnTurretToX = e.stageX;
			turnTurretToY = e.stageY;

			turretAtan2 = Math.atan2(turnTurretToY - currentTankPositionY, turnTurretToX - currentTankPositionX);

			if (Math.round(turretAtan2 * 180 / Math.PI) < 0) {
				angle = Math.round(turretAtan2 * 180 / Math.PI) + 360;
			} else {
				angle = Math.round(turretAtan2 * 180 / Math.PI);
			}

			if (angle > 240 && angle < 300) {
				tank.mTurret.gotoAndStop(1);
			}
			if (angle > 300 && angle < 340) {
				tank.mTurret.gotoAndStop(2);
			}
			if ((angle >= 0 && angle < 20) || (angle > 340 && angle <= 360)) {
				tank.mTurret.gotoAndStop(3);
			}
			if (angle > 20 && angle < 60) {
				tank.mTurret.gotoAndStop(4);
			}
			if (angle > 60 && angle < 120) {
				tank.mTurret.gotoAndStop(5);
			}
			if (angle > 120 && angle < 160) {
				tank.mTurret.gotoAndStop(6);
			}
			if (angle > 160 && angle < 200) {
				tank.mTurret.gotoAndStop(7);;
			}
			if (angle > 200 && angle < 240) {
				tank.mTurret.gotoAndStop(8);
			} 

		}

		private function mouseDownListener(e:MouseEvent):void {

			moveTankToX = e.stageX;
			moveTankToY = e.stageY;
			addEventListener(Event.ENTER_FRAME,moveTankOnEnterFrame);

		}

		private function moveTankOnEnterFrame(e:Event) {

			moveToCoordinates(tank, moveTankToX, moveTankToY);
		}

		private function moveToCoordinates(tank_mc:Tank, tX:Number, tY:Number) {

			var angle:Number; 

			if (Math.round(Atan2 * 180 / Math.PI) < 0) {
				angle = Math.round(Atan2 * 180 / Math.PI) + 360;
			} else {
				angle = Math.round(Atan2 * 180 / Math.PI);
			}

			if (angle > 240 && angle < 300) {
				tank.gotoAndStop(1);
			}
			if (angle > 300 && angle < 340) {
				tank.gotoAndStop(2);
			}
			if ((angle >= 0 && angle < 20) || (angle > 340 && angle <= 360)) {
				tank.gotoAndStop(3);
			}
			if (angle > 20 && angle < 60) {
				tank.gotoAndStop(4);
			}
			if (angle > 60 && angle < 120) {
				tank.gotoAndStop(5);
			}
			if (angle > 120 && angle < 160) {
				tank.gotoAndStop(6);
			}
			if (angle > 160 && angle < 200) {
				tank.gotoAndStop(7);
			}
			if (angle > 200 && angle < 240) {
				tank.gotoAndStop(8);
			}

			clickPoint = {x:moveTankToX, y:moveTankToY};
			Atan2 = Math.atan2(clickPoint.y - tank_mc.y, clickPoint.x - tank_mc.x);

			tank_mc.x += Math.cos(Atan2) * tankSpeed;
			tank_mc.y += Math.sin(Atan2) * tankSpeed;

			currentTankPositionX = tank_mc.x;
			currentTankPositionY = tank_mc.y;

			if (Math.abs(tank_mc.x - clickPoint.x) < 15 && Math.abs(tank_mc.y - clickPoint.y) < 15) {

				removeEventListener(Event.ENTER_FRAME,moveTankOnEnterFrame);
			}
		}
	}
}

Step 25: Final Strokes

Go to File > New, and create a new ActionScript file. Save it as “Game.as” in the same folder as your tank.fla file. This will be our document class.

Here’s the code for Game.as class:

package {

	import flash.display.*;
    // import the contents of our main folder
	import main.*;

	public class Game extends MovieClip {

		private var newTank:TankMaker;

		public function Game () {

            // create a new instance of our tank maker class
			newTank = new TankMaker();
            // and add it to the stage of course
			addChild(newTank);
		}
	}
}

Save the file. All it does is create a tank and add it to the main stage, ready to control.

Step 26: Attach Game Class to the FLA

Open up tank.fla and go to the Properties panel. For Class type in “Game” and save the file.

Aha! There we go. You can now press CTRL + ENTER on PC (CMD + RETURN on Mac) and test the Game.

I hope you enjoyed this tutorial, thanks for reading :)

Just work 1 hour everyday(work from home) by irfanmo84

Earn Rs.35,000-Rs.50,000 per month from home No marketing / No MLM . We are offering a rare Job opportunity where you can earn from home using your computer and the Internet part-time or full-time. Qualifications required are Typing on the Computer only… (Budget: $250-750, Jobs: Bulk Marketing, Data Entry, Data Processing)

Australian Telco Telesales Campaign – Commission based by OHMI

Australian Telco looking for experienced telemarketing agents to sell mobile phone campaign to australian consumers. Must have experience in telesales, must have excellent english – will be tested prior to dialing, quality VoIP connection required… (Budget: $250-750, Jobs: Sales, Telemarketing)

Vintage photos site needs 1950-ish design touch using CSS by Flygfotohistoria

Hi there! I am marketing old aerial photographs and run a web site / shop that uses a database and that is constructed using HTML code and Ruby on Rails. You will be in connection with the person that has set this up and is running it… (Budget: $750-1500, Jobs: CSS, HTML, Website Design)