Be a Supporter!
Response to: Flash Developer Question Posted August 22nd, 2013 in Game Development

At 8/22/13 03:25 AM, kkots wrote: Yes, export the entire flash library from your FLA to an SWC file and then attach that SWC to the Flash Developer project, and use Flash Developer to compile the game, not just edit actionscript files.

What if say I don't have all the library assets finished? Like say I added more items to the library would I just do everything you said again and replace the previous SWC?

Flash Developer Question Posted August 22nd, 2013 in Game Development

So I've been learning AS3 for past couple of months. Up until this point I was just coding inside Flash Professional, not on frames but in it's own .as files, but I just downloaded Flash Developer as you guys, and others online, have recommended that it is much better to code with.

My question is this: Is there anything you guys think I should know before I dive into it or do I just treat it like any other .as file like I had inside Flash Pro? Any advice or tips?

Just thought it was worth asking you guys.

Thank you :)

Response to: Quick Q: Stage boundary test Posted August 21st, 2013 in Game Development

At 8/21/13 01:59 AM, Aka-Star wrote: you want to set the player.x +=vx before you do the boundary test

Ahhh thank you dude. I knew it was something simple. I will have to really start paying more attention to the order of things in my coding.

Really appreciate the help! :D

Quick Q: Stage boundary test Posted August 21st, 2013 in Game Development

Odd thing happening to me that I'm sure is me overlooking something small. Just doing a simple boundary test to stop player from leaving sides of stage. I've done this before in other little test games but something funky is happening this time.

The player (which is just a box now as a placeholder) is managing to get a few frames outside of stage before bouncing back after letting go of the movement key.

package
{
	import flash.display.MovieClip;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.events.Event;
	
	public class Main extends MovieClip
	{
		var vx:int;
		var playerHalfWidth:uint;

		
		public function Main()
		{
			init();
		}
		function init():void
		{
			//Initialize variables
			vx = 0;
			playerHalfWidth = player.width / 2;

			//Add event Listeners
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
			stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
		}
		function onKeyDown(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.A || event.keyCode == Keyboard.LEFT)
			{
				vx = -5;
			}
			else if (event.keyCode == Keyboard.D || event.keyCode == Keyboard.RIGHT)
			{
				vx = 5;
			}
		}
		function onKeyUp(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.A || event.keyCode == Keyboard.D)
			{
				vx = 0;
			}
			if (event.keyCode == Keyboard.LEFT || event.keyCode == Keyboard.RIGHT)
			{
				vx = 0;
			}
		}
		function onEnterFrame(event:Event):void
		{
			//Stop player at edge of stage
			if (player.x + playerHalfWidth > stage.stageWidth)
			{
				player.x = stage.stageWidth - playerHalfWidth;
			}
			else if (player.x - playerHalfWidth < 0)
			{
				player.x = 0 + playerHalfWidth
			}
			
			//Move the player
				player.x += vx;
		}
	}
}

All of this is just inside of the Document Class. Just move left or right with Arrows or A/D. Move to the edge and you will see box nearly stop at edge but when letting go of movement key the player slightly bounces back into stage.

Here is test:
<a>
http://www.newgrounds.com/dump/item/c3b9dff5a781f03eff01ed5604c71ab8
</a)

What am I missing?

Thanks in advance guys

Response to: OOP what goes on document class? Posted August 3rd, 2013 in Game Development

Thank you for your input MSGhero. You are always on here responding to my AS3 questions and I just want you to know that I greatly appreciate all the help you have given me :)

swapChild needed for this? Posted August 3rd, 2013 in Game Development

In games like Chibi Knight or Knightmare Tower (two I can think of off the top of my head) the character gains experience through actions and then levels up. After leveling up you can up grade/buy attributes to make yourself a better character.

For example, if you choose to upgrade armor your characters armor visibly changes to something else or if you choose to upgrade strength you get a cool new looking sword (obviously stats go up to but I'm focusing on the visuals here...).

With AS3 coding, is this done with something like swapChild? Like how is it that your character has all his movements and attack animations with one sword and then suddenly with a new one that replaced the old one yet works the exact same?

Would I have to create a whole new MC with the new sword in all the movement and attack animations. Seems like a lot of work not needed.

Is there another way? Am I getting warm with swapChild?

Thanks in advance guys for all your help :)


When using OOP is there anything that just be tied to the Document Class? As I understand it, and please correct me if I am wrong as I am still trying to grasp OOP, whatever you place in the class that is tied to the document carries over throughout the entire game rather than just say everything that was on the first level.

Trying to figure out what should go in the document class (for example, character movement which remains the same throughout whole game) and what can be given its own class.

I know it may be vague as I am not giving details about the game and that's cuz I don't have any. I'm talking hypothetically if I were to make a game (and I plan too as I've been plugging away at programming for months) how do I know what needs there own class and what can go in the document class?

Thanks in advance guys. You are always so helpful :)

Response to: Grasping OOP... Posted August 2nd, 2013 in Game Development

Sorry for the late reply I was out of town with no way to get online.

Wow.... So many awesome response from you guys! Thank you so much!!! I will definitely be taking all this wonderful advice you guys have given me and put it to good use (and lots and lots of practice).

Thanks again so much for everyone's amazing input :)

Grasping OOP... Posted July 30th, 2013 in Game Development

I've been learning how to program AS3 Flash games through a book meant for beginners (have to start somewhere right?) over the past 6 months in what free time I have (damn you college). Everything has been going great and I've learned enough to make simple games so far.

Then....I got to this large chapter that went into OOP. Now up until this point I took my time experimenting with code each time I did a chapter so that I could be grasp the code I learned and it has worked great for me so far. But now with OOP and no longer working with just 1 class I am having difficulty wrapping my head around it all.

What I don't really understand using getters get and setters set. I know that's how the different classes communicate with one another but when I look at code examples of it it confuses me a little.

Also I can't understand when I should use private or public functions. I still don't quite get what it means to have a static function either....

Sorry for the long post... I was just curious how all you programmers here went about mastering OOP? Any advice would be greatly appreciated.

Thanks in advance :)

Response to: How to start out as a total noob Posted July 29th, 2013 in Game Development

I used this book to learn AS3 programming: http://www.amazon.com/gp/product/1430218215/ref=oh_details_o 06_s00_i00?ie=UTF8&psc=1

It has helped me a lot as I grow as a Flash game developer. Might be worth a try :)

Response to: Stuck on something [AS2] Posted July 28th, 2013 in Game Development

Alright thanks for the tips, any idea where the best place to start AS3 is? (I know Google is great, I just prefer recommendations from people over blind searching.)

This: http://www.amazon.com/gp/product/1430218215/ref=oh_details_o 06_s00_i00?ie=UTF8&psc=1 I took up programming in AS3 about 6 months ago and this book has been amazing. It's really great for beginners. Do yourself a favor and get it haha

Good luck :)

Response to: Stage Movement Posted July 23rd, 2013 in Game Development

At 7/19/13 12:54 AM, UltimatumVox wrote: I think I'm alright.

Wouldn't want to do myself wrong. I accept your advice and will give AS3 a try.

Dude I highly suggest you get this book to learn game coding for AS3 as a beginner

http://www.amazon.com/gp/product/1430218215/ref=oh_details_o 06_s00_i00?ie=UTF8&psc=1

Even if you know a bit of coding in AS2 this book will really help you grasp AS3 and it's pretty fun making games and learning fundamentals that build on each chapter. Definitely worth it in my opinion.

Response to: Flash AS2 enemy rotation to player! Posted July 23rd, 2013 in Game Development

At 7/23/13 12:06 AM, MintPaw wrote: If you're just learning programming I highly suggest learning AS3, it's similar to AS2 and free. AS2 is as outdated as Windows 98 at this point.

I totally agree with MintPaw. You should definitely look into learning AS3. If you are just starting out I highly suggest this book

http://www.amazon.com/gp/product/1430218215/ref=oh_details_o 06_s00_i00?ie=UTF8&psc=1

Author explains everything really well, has great pacing, and is overall fun if you are just starting out.

Response to: Programming help for a non programm Posted July 22nd, 2013 in Game Development

Hello all, and thank you for reading this thread. I am an animator and have been working on game assets for a game that I want to create, but am having such a hard time grasping AS. I took a few classes, and have a few books, but just cannot get it down. I was wondering if there are programs that will do the code for me, where I plug my assets and then can decide with drop down menus what is supposed to happen? sort of a wysiwyg type of program.

I don't think there are any programs like that dude when it comes to AS. I'm recently new to coding myself. Been doing it in my free time (when college allows it) over the past couple of months. Like you, I bought a book and have been using it to learn.

I'm not sure what book(s) you are trying to learn from but I do know there are some AS books that are either too advance for beginners or they are not well put together. I suggest you get this book

http://www.amazon.com/gp/product/1430218215/ref=oh_details_o 06_s00_i00?ie=UTF8&psc=1

It is the only I am learning with. The author explains everything in detail as if you are a total beginner to both Flash and AS. I've learned enough to make certain games already and I'm not even finished with the book. Highly recommend it for beginning programmers as the author explains everything so well (he also is humorous which helps too haha).

Good luck with programming dude! Don't give up!

Response to: addChild into nested MC??? Posted July 22nd, 2013 in Game Development

At 7/15/13 10:59 AM, kkots wrote: Here's Adobe Flash ActionScript 3.0 API Reference.
On your current stage of development as a coder, you may really want to read about MovieClip, Sprite, DisplayObject, DisplayObjectContainer. Those pages contain information on functions such as "addChild", "setChildIndex" (in DisplayObjectContainer) that you will find verrrry useful!

Whoa.... I've been looking for a source like this online! Thank you so much for the heads up! I will definitely be using it as I continue to grow as a programmer. Thanks again :)

Response to: AS3 disable event listener controls Posted July 21st, 2013 in Game Development

When your list of booleans gets really long and annoying to deal with, the stuff in Diki's tut is the next step to simplifying the code.

Whoa looks intense haha Will definitely be jumping back to it after I get more experience coding. Thank you so much for
all of your help. It is greatly appreciated :)

Response to: AS3 disable event listener controls Posted July 21st, 2013 in Game Development

At 7/21/13 12:36 AM, MSGhero wrote: The simple(r) way is to have a boolean variable for each key. When the player presses up, set keyUp to true. If keyLeft is true, then keyRight should be ignored. Then in your enterframe handler, check if any of those booleans are true and move the player from there.

Dude that's a great idea! I'll give it a try. Thank you :)

Response to: AS3 disable event listener controls Posted July 21st, 2013 in Game Development

I got it to work my way

package
{
	import flash.display.MovieClip;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.events.Event;
	import flash.events.MouseEvent;

	
	public class Main_Boxcar extends MovieClip
	{
		//Add var to stage
		var vx:int;
		var vy:int;

		
		public function Main_Boxcar()
		{
			init();
		}
		function init():void
		{
			
			//Players velocity
			vx = 7;
			vy = 0;
			
			//Initialize objects
			
			
			//Add event Listeners
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownA);
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownS);
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownW);
			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownD);
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
			

		}
		function onKeyDownA(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.A)
			{
				vx = -7;
				vy = 0;
				stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownW);
				stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownD);
				stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownS);
			}
		}
		function onKeyDownS(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.S)
			{
				vx = 0;
				vy = 7;
				stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownA);
				stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownW);
				stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownD);
			}
		}
		function onKeyDownW(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.W)
			{
				vx = 0;
				vy = -7;
				stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownS);
				stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownD);
				stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownA);
			}
		}
		function onKeyDownD(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.D)
			{
				vx = 7;
				vy = 0;
				stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownA);
				stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownS);
				stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownW);
			}
		}

		function onEnterFrame(event:Event):void
		{
			
			//Move the player
			player.x += vx;
			player.y += vy;
			
			//Collision
			if (player.hitTestObject(centerWall))
				{
					vx = 0;
					vy = 0;
				}
		}
	}
}

But I know this isn't the most efficient way to do this..... So any input would be greatly appreciated.

Would love to figure out how to do this with just a single event listener for KEY_DOWN

Response to: AS3 disable event listener controls Posted July 20th, 2013 in Game Development

At 7/20/13 08:49 PM, Sam wrote: You can use the code tags (noted to the left of the post box) to preserve code formatting which makes it much easier to read. At first glance I can tell you that you don't need to have a listener for each key, you can do what you're trying to with a single listener. It's much better to do it with one listener for various reasons. First collate all those functions and repost the code and I'll take a better look.

Thanks for tip on code tags. I am aware how to consolidate everything into a single listener. I did this originally but couldn't figure out a way to disable key presses for other keys - that's why I gave them each their own listener. Nonetheless I did as you asked:

package
{
	import flash.display.MovieClip;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.events.Event;
	import flash.events.MouseEvent;

	
	public class Main_Boxcar extends MovieClip
	{
		//Add var to stage
		var vx:int;
		var vy:int;

		
		public function Main_Boxcar()
		{
			init();
		}
		function init():void
		{
			
			
			//Players velocity
			vx = 7;
			vy = 0;
			
			//Initialize objects
			
			
			//Add event Listeners

			stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
			stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
			addEventListener(Event.ENTER_FRAME, onEnterFrame);
			

		}
		function onKeyDown(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.A)
			{
				vx = -7;
				vy = 0;
			}
			else if (event.keyCode == Keyboard.S)
			{
				vx = 0;
				vy = 7;
			}
			else if (event.keyCode == Keyboard.W)
			{
				vx = 0;
				vy = -7;
			}
			else if (event.keyCode == Keyboard.D)
			{
				vx = 7;
				vy = 0;
			}
		}
		function onKeyUp(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.A || event.keyCode == Keyboard.D)
			{
				vx = 0;
			}
			else if (event.keyCode == Keyboard.S || event.keyCode == Keyboard.W)
			{
				vy = 0;
			}
		}
		function onEnterFrame(event:Event):void
		{
			
			//Move the player
			player.x += vx;
			player.y += vy;
		}
	}
}

For now my UP state for key presses is set to just stop motion. I want it so that, for example, the player presses A to make character move left that all other keys are disable except S so that he can only move down (again, only want player to be able to move in a square going counter clockwise).

Thanks in advance for any help!


Trying to make a car that can only make right angle turns (going counter clockwise). Just practicing with AS3 coding to better help me grasp concepts before I move on to the next chapter (learning programming from a book).

I want to make it so that when the player hits W the character goes up AND at the same time disable all other controls except for A (if the player is making only right angle turns in counter clockwise motion then after W makes the player go A would allow player to turn left). Same thing if hit S for down movement then disable all controls except for D to go right.

Here is my code:

package
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;
import flash.events.MouseEvent;

public class Main_Boxcar extends MovieClip
{
//Add var to stage
var vx:int;
var vy:int;

public function Main_Boxcar()
{
init();
}
function init():void
{

//Players velocity
vx = 7;
vy = 0;

//Initialize objects

//Add event Listeners
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownA);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownS);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownW);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownD);

stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);

addEventListener(Event.ENTER_FRAME, onEnterFrame);

}
function onKeyDownA(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.A)
{
vx = -7;
vy = 0;
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownW);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownD);
}
}
function onKeyDownS(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.S)
{
vx = 0;
vy = 7;
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownA);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownW);
}
}
function onKeyDownW(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.W)
{
vx = 0;
vy = -7;
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownS);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownD);
}
}
function onKeyDownD(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.D)
{
vx = 7;
vy = 0;
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownA);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDownS);
}
}
function onKeyUp(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.A)
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownS);
}
else if (event.keyCode == Keyboard.S)
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownD);
}
else if (event.keyCode == Keyboard.W)
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownA);
}
else if (event.keyCode == Keyboard.D)
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDownW);
}
}
function onEnterFrame(event:Event):void
{

//Move the player
player.x += vx;
player.y += vy;
}
}
}

The problem is this: say player press A and moves to the left. If the player were to hit D (right) nothing would happen which is great cuz that's what I wanted to have happen yet by the player hitting D it re-enables the EventListener for the key W which would allow the player to make a change in direction that is outside of the counter clockwise motion.

Any help would be greatly appreciated. Hope I explained this clearly. Feel like it came out confusing while typing this up.
Any questions just ask.

Thanks in advance guys!

Response to: addChild into nested MC??? Posted July 15th, 2013 in Game Development

That's because "addChild" is shorthand for "this.addChild" and "this" is your main game container, which is a sprite or mc (you usually don't have to write "this" out). So it always ends up being thing2.addChild(thing1) in one form or another.
public class Main extends SPRITE if you're in FD. The timeline is a MC if you're in Flash.

Ah ok I get it. Thank you for caring to educate me on this. Really appreciate it :)

Response to: addChild into nested MC??? Posted July 15th, 2013 in Game Development

Sure, just mc.addChild(kid);

Thank you! I only knew of addChild(mc1) and it never crossed my mind that mc2.addChild(mc1) was a possibility.

I still have much to learn, heh...

Thanks again dude!

addChild into nested MC??? Posted July 15th, 2013 in Game Development

Coding with AS3. I've already loaded a MC from the library to the stage. Was curious if it was possible to load another MC to the stage (which I know you can) but nest it inside another MC?

I've tried but I get the error :TypeError: Error #2007: Parameter child must be non-null.

Is it possible?

Thanks in advance guys.

Response to: Level design question... Posted July 13th, 2013 in Game Development

That's because your question probably gave away your huge lack of skills, and forum regulars do not like people who don't know anything or have no skills at the area in which they seek help, so they simply sent you to hells instead of bothering to teach you everything from very basics.

Thanks.... I know this now. I was talking about years ago when I asked. I wouldn't have bothered to ask now if I didn't know anything.

Nitokov: Oh I'm more than just curious dude. I've been teaching myself to program for a couple of months. I stated in my original post that I won't be able to make a decent game probably for a year. I know enough now to make very basic games like click adventures. I recently learned about programming side scrolling and parallax scrolling and thus it made me curious to ask this question. Just trying to wrap my head around it all as I continue to learn and experiment with code :)

Response to: Level design question... Posted July 12th, 2013 in Game Development

Thank you for all the awesome feedback guys! I really debated whether I should bother seeking knowledge on the forums cuz there have been times in the past (years ago when I was asking questions about animation before I knew coding) and would just get really rude/pointless replies. Thanks to you guys I feel like I can reach out to the programming community here! Which is great cuz I have so much to learn but I will try to figure it out on my own so I do not bombard the forums with too many questions haha :)

Response to: Programmers/Artis ts opinion needed Posted July 12th, 2013 in Game Development

K-Guare: Thanks for the input dude and thank you for also responding to my other post too! You're awesome for that!

kkots: Dude I know man. I've seen all those posts of people wanting to collaborate with no skills of their own. I never plan to do it which is also why I said I won't be able to make a decent game for like a year. I'm the kind of guy that doesn't want to collaborate on anything in life unless I am confident in my own skills first haha

Thank you everyone for your inputs! I will keep plugging away at learning how to code better. Making little demo games where I experiment with each new code I learn is really helping it "stick" in my head and better grasp it all. Maybe one day I will try to collaborate in the future but I'm gonna try and make simple games by myself once I know enough coding to do so.

Thanks again everyone!

Response to: Level design question... Posted July 11th, 2013 in Game Development

Thanks buddy I really appreciate the advice!

Level design question... Posted July 11th, 2013 in Game Development

So I've been teaching myself how to code in AS3 and recently learned how to program your character to move through side-scrolling as well as parallax scrolling. This got me thinking....

Say in a side-scrolling game the character's horizontal velocity is just a slow pace (5) and it is running at 30fps. That's 180 pixels per second. In 10 seconds that would be 1,800. That means that you would have to design a level that is really long (1800 is a lot) and even then that would be one short ass level despite the character jumping gaps, killing enemies, and collecting items. At 30 seconds it would be 5,400 (that's huge!).

So my question is how do you draw out a level that long??? Do you do it in segments that are the size of your stage and just stitch them together? Do you guys make these long levels in Flash or make a template in another program? I'm really confused how you do this.... I'm a long way away from knowing enough programming to make a game but I was just really curious how you make this kind of side scrolling level that stretches so long.

Thanks in advance guys!

Response to: Programmers/Artis ts opinion needed Posted July 11th, 2013 in Game Development

For the record, I'm capable of doing the art and animation myself; however, doing both the art and programming would potentially double the length of time it would take to make a game by myself.

Response to: Programmers/Artis ts opinion needed Posted July 11th, 2013 in Game Development

Really appreciating the responses guys!

Anyone else that would like to give their 2 cents feel free to state your view.