Be a Supporter!
Response to: addChild game after api??? Posted January 19th, 2014 in Game Development

Also I still don't know if I'm suppose to give the API connector on the first frame an instance name. I've left it blank this whole time.

Response to: addChild game after api??? Posted January 19th, 2014 in Game Development

At 1/19/14 11:06 PM, egg82 wrote: as far as I'm aware:

private var ad:FlashAd = new FlashAd();

//in whatever main function you have
ad.playButton.addEventListener(MouseEvent.MOUSE_UP, onAdPlayBtnMouseUp);

private function onAdPlayBtnMouseUp(e:MouseEvent):void {
ad.removeEventListener(MouseEvent.MOUSE_UP, onPlayBtnMouseUp);

//do stuff here, line below is an example
StateEngine.swapStates(MenuState);
}

Thanks for the reply. Sadly this it really didn't like this line:

private var ad:FlashAd = new FlashAd();

through a whole bunch of errors at me :(

I really do appreciate everyone trying to help me tho...

Response to: addChild game after api??? Posted January 19th, 2014 in Game Development

At 1/19/14 10:37 PM, Hero101 wrote: oh since I'm dragging the Api connector MC onto the stage in the first frame should I just give it the instance name flashAd cuz I just realized it doesn't have an instance name in my project.

Yes I'm using Flash Pro

Nevermind disregard that cuz it didn't work

Response to: addChild game after api??? Posted January 19th, 2014 in Game Development

oh since I'm dragging the Api connector MC onto the stage in the first frame should I just give it the instance name flashAd cuz I just realized it doesn't have an instance name in my project.

Yes I'm using Flash Pro

Response to: addChild game after api??? Posted January 19th, 2014 in Game Development

flashAd.playButton.addEventListener(MouseEvent.CLICK, startGame);

The play button is a public mc that you can add additional listeners to. It removes the ad by default.

I did that and then made the function:

function startGame(event:MouseEvent):void
			{
				addChild(gameCon);
			}

But I got the error: 1120: Access of undefined properity flashAd

Does this mean I need to do:

flashAd:FlashAd;
flashAd = new FlashAd():

??

addChild game after api??? Posted January 19th, 2014 in Game Development

So I just started messing around with newgrounds Api. I followed the steps of downloading it, copy the api file into my game's .fla, dragging the api connector onto the first frame, clicking the MC and entering the Api ID and Encryption Key in the property panel. Everything works when I tested it.

However, when I click the play button it removes the api MC and I'm left with a blank stage. How do I make it so that when I click the API's play button that it addChild's my game's first level?

Been trying to find the answer for awhile on youtube and here on the forums but it's just people having issues with ads or medals. I just want the API for now.

Thanks in advance

Response to: Making dynamic txt fields fade out? Posted January 18th, 2014 in Game Development

This long line confuses the heck out of me

GameMain.getInstance().getTweenManager().add(function(o:DisplayObject, frameComp:Number):void {
Response to: Making dynamic txt fields fade out? Posted January 18th, 2014 in Game Development

Damn....didn't think it was gonna take that much work (although it probably is easy to you guys). The code above is rather new to me and so is the concept of integrating it with a bitmap... I'll have to tinker around with it and see if I can get it to work.


So I made a simple turn-based game where players take turns attacking each other. I want to be able to display the damage that a player receives (currently their hp just drops). You know, like games like Castle Crashers or many tower defense games where an enemy takes damage and it displays how much damage you did.

Now I can probably figure out the coding for displaying the damage output using dynamic text fields.

What I don't know how to do is:

1. How do you fade out the text field? Like say you do 10 damage and it displays "-10" to show you did that much damage. I don't want that -10 to just hang up there until the next strike. I want it to display the damage (in this example -10) and then have it fade out (invisible).

2. This is just more for looks but how would I make it so that the damage, say -10 again, had a tween to it. Like it started at one position and then gradually moved up a few pixels (all while doing the fade out function listed above)?

Thanks in advance guys.

Response to: Call Btn in MC w/o dot notation??? Posted January 15th, 2014 in Game Development

ADDITIONALLY: How in the world do you call a function in another class? I know it is possible... Using the same test I mentioned in the first post I added a 3rd button "btnBoom" and when it is clicked I want it to call the function "goGreen" in a different class.

Here's the Level_Loader class that is in my doc class:

package 
{
	
	import flash.display.MovieClip;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class Level_Loader extends MovieClip
	{
		public var mcColor:McColor;
		public var btnBlue:BtnBlue;
		public var btnRed:BtnRed;
		public var btnBoom:BtnBoom;

		public function Level_Loader()
		{
			mcColor = new McColor;
			addChild(mcColor);
			mcColor.stop();
			
			btnRed = new BtnRed;
			btnBlue = new BtnBlue;
			btnBoom = new BtnBoom;
			
			mcColor.btnBlue.addEventListener(MouseEvent.CLICK, onBtnBlue);
			mcColor.btnRed.addEventListener(MouseEvent.CLICK, onBtnRed);
			mcColor.btnBoom.addEventListener(MouseEvent.CLICK, onBtnBoom);
			
			function onBtnBlue(e:MouseEvent):void
			{
				mcColor.gotoAndStop(2);
			}
			function onBtnRed(e:MouseEvent):void
			{
				mcColor.gotoAndStop(3);
			}
			function onBtnBoom(e:MouseEvent):void
			{
				gameManager.goGreen();
			}
		}

	}
	
}

and the other class that contains the function I'm trying to call:

package 
{
	
	import flash.display.MovieClip;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class gameManager extends MovieClip
	{
		

		public function gameManager()
		{
			function goGreen(e:MouseEvent):void
			{
				mcColor.gotoAndStop(4);
			}
		}

	}
	
}

As you can see I tried accessing the goGreen function in the gameManager class like this:

function onBtnBoom(e:MouseEvent):void
			{
				gameManager.goGreen();
			}

but that failed.

Can someone give me a coding example on how to call a function in another class. Explaining would be great but I feel I need to see a code example to really make it click as I've been at this for hours trying to figure it out to no avail.

Thanks in advance guys.


I have a Movieclip called mcColor. Inside of it are three frames of the same rectangle with different colors: purple, blue, red. On an addition layer inside the same mcColor Movieclip is two buttons: btnBlue (go to blue frame) and btnRed (go to red frame). Simple enough right?

Here's the code:

package 
{
	
	import flash.display.MovieClip;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class Level_Loader extends MovieClip
	{
		public var mcColor:McColor;
		public var btnBlue:BtnBlue;
		public var btnRed:BtnRed;

		public function Level_Loader()
		{
			mcColor = new McColor;
			addChild(mcColor);
			mcColor.stop();
			
			btnRed = new BtnRed;
			btnBlue = new BtnBlue;
			
			btnBlue.addEventListener(MouseEvent.CLICK, onBtnBlue);
			btnRed.addEventListener(MouseEvent.CLICK, onBtnRed);
			
			function onBtnBlue(e:MouseEvent):void
			{
				mcColor.gotoAndStop(2);
				trace ("blue");
			}
			function onBtnRed(e:MouseEvent):void
			{
				mcColor.gotoAndStop(3);
				trace ("red");
			}
		}

	}
	
}

Here is what I'm trying to figure out.... The above code is how I want it to work, however, it does not. I have to fix the two event listeners for the buttons above by adding the mcColor like so:

mcColor.btnBlue.addEventListener(MouseEvent.CLICK, onBtnBlue);
			mcColor.btnRed.addEventListener(MouseEvent.CLICK, onBtnRed);

I know there has to be a way to do it like in the first piece of code I showed at the top. Because for example say in a game I had walls, items, or enemies inside of this movie clip that the player interacts with. Having to do a lot of dot notations would be impractical I would think.

For now I'm just trying to add a listener to a button inside a movieclip without having to add the movieclip name to listener. How do you do this?

Response to: Experienced programmer needed Posted January 14th, 2014 in Game Development

Sorry Pall but you are not going to get any bites around here without posting more details. Too often beginners post things like this or it is a scam. If you want people to join your cause then provide more information. Provide a link to your website or portfolio so people know you have knowledge as well. Preferably a portfolio that includes something you've done with programming yourself so programmers here know you understand just how difficult and time consuming coding is. Just some tips if you want to greatly improve your chances of anyone sending you a message.

Response to: How do you call certain classes??? Posted January 11th, 2014 in Game Development

Oh ok. Thanks for the link I appreciate it.

Response to: How do you call certain classes??? Posted January 11th, 2014 in Game Development

Oh I think I understand...

Two questions:

What does Global mean? I've never seen that before.

And could you please explain Static. I've only ever know public and private variables.

Response to: How do you call certain classes??? Posted January 11th, 2014 in Game Development

Additionally, if I called a class that was say player vs CPU how would I remove it if say the player went back to main menu and chose player vs player


So I made a simple player vs player game (it was more of a demo test I made after learning some new code). Now with what coding knowledge I have (AS3) I know I could figure out how to make it also player vs CPU.

My question is this: Say I have an intro screen where the player selects either player vs player or player vs CPU - how would I make it run a specific class depending on the game mode chosen?

Right now my little game just has one Game_Manager class that I run through the doc class. I know I would need the Game_Manager not in the doc class and instead have like a LevelLoader class call in the game mode. Just did it that way cuz I was still very new to coding when I made this demo back in the summer.

Thanks in advance guys.

Response to: 2nd monitor for coding? Posted January 11th, 2014 in Game Development

Wow such awesome responses from everyone. Thank you all so much for your input :)

2nd monitor for coding? Posted January 11th, 2014 in Game Development

I'm curious how you guys have a setup for working on your games.

You see I have been making my games with Flash and coding inside of it as well with classes. I work on a laptop. My latest game demo has 660 lines of code. It's becoming a little bit of a pain to click on the separate tab to go to where my coding is and it's even more of a pain to scroll down through all that coding on my laptop.

So I was wondering if it would be a good idea (or wondering if you fellow coders do this as well) to attach an external monitor to my laptop and rotate it vertically and use it for just my coding? That way I can work on the art side of things on my laptop while coding on the other.

What do you guys think? What do you guys do for your workflow?

Response to: Problem with Flash Posted January 11th, 2014 in Game Development

At 1/10/14 07:14 PM, Ieva wrote: Hello everyone. There's a one thing which separate me from fluently animation making. When I try to use paint bucket tool, my drawing doesn't paint, but some weird crashes with lag appear. Is it Flash problem, or me stupid again? Thank You.

I don't fully understand your question. What exactly are you trying to fill with your paint bucket tool? Shapes, lines, brush strokes? As for the lag does this happen when trying to use paint bucket tool? Shouldn't be lagging at all for trying to use the paint bucket.

Response to: Brush Problems! Posted January 3rd, 2014 in Game Development

You could also select there circle and then click the smoothing tool in the tools panel as many times as needed. It works well but you don't have any control over how it alters the shape to smooth it out.

Response to: Toggle btn issue after init(); Posted December 31st, 2013 in Game Development

Remove all listeners and children.

You want to reset the thing to how it was before you called init OR only reset the variables and leave the adding and removing alone.

Ok I get it. Thank you for your help. I'm gonna go give it a try.

Thanks again :)

Response to: Toggle btn issue after init(); Posted December 31st, 2013 in Game Development

You would do the opposite of everything you did in init, and then call init again.

So like maybe when the player clicks replay button

function replayBtn (e:MouseEvent):void
{
//remove all event listeners
//call init
}

would that work?
Sorry if I'm having trouble understanding..

Response to: Toggle btn issue after init(); Posted December 31st, 2013 in Game Development

Right now all my coding for the game is in the init() function. What if I added a sub function into init() that would contain all the coding currently in init() and just have init() contain the event listeners?

Would that work. Then when player hits replay button it just calls subfunction like you said. But would the event listeners in init() still be active?

Response to: Toggle btn issue after init(); Posted December 31st, 2013 in Game Development

Your init function probably adds things, children or listeners or whatever. When you call init again, those things get added again and that can mess up existing objects. You should either remove everything and then readd it or have a subfunction in init that resets all the variables but doesn't actually add anything. Then call that instead of init.

Oh I did not know that could mess things up. This is how I've always done it and this is the first time I've notice it causing a problem.

How would I go about removing everything and then re-add it? I think I can probably figure out the subfunction option....maybe.

Response to: as2 point and click game help Posted December 31st, 2013 in Game Development

the problem:
i learned to pick up and use items but its just like: click to the item and the door is open automaticly. i want to activate items like this: u click the inventory choose 1 item and after that u need to click the correct objectum and only this case happening something. thx!

I don't know AS2 but nonetheless to do what you are wanting to do you need to look into Booleans. They work in true (yes) or false (no) in your code.

for example if your player touched a door it could check to see if the player had the key to open it (true) or nothing happens if he doesn't have key (false):

playerHasKey:Boolean = false; //player doesn't have key so it's false

if play.hitTestObject(key) //if player touches key
{
    playerHasKey = true  //player now has key
}

if player.hitTestObject(door)
{
     if (playerHasKey) //checks to see if boolean is true
         {
            doorOpen();  //function that would open door
         }
}

Again, I don't know AS2 but if you have a good grasp of it you should be able to understand the code above

Response to: Toggle btn issue after init(); Posted December 31st, 2013 in Game Development

Note: Even if the btnMap is visible - as soon as the replay but is hit and init(); runs to set up new game - the btnMap disappears visibly at the start of the new game. Now I'm guess this is because I state it to start invisible at start of game but function to make visible isn't working.

Response to: Toggle btn issue after init(); Posted December 31st, 2013 in Game Development

I've even tried making it a boolean. Like say:

mapShowing:Boolean;
mapShowing = false;

//Then in the function listed above for the button mouse event listener do:

if (!mapShowing)
{
      btnMap.visible = true;
}
if (mapShowing)
{
     btnMap.visible = false;
}

No luck.

Toggle btn issue after init(); Posted December 30th, 2013 in Game Development

In my test game I have a button that I want to toggle on and off an MC that shows the player's controls.

public function Game_Manager()
		{
			init();
		}
		function init():void
		{
                      btnMap.visible = false;
                     showBtnMap.addEventListener(MouseEvent.CLICK, onShowBtnMap);
                     
                      //rest of code for game

                      function onShowBtnMap(event:MouseEvent):void
			{
				btnMap.visible = !btnMap.visible;
			}
                   }

Now the code works. I click on the button (showBtnMap) and the MC (btnMap) turns on and off (visibility wise). This is great and all until when the game is over and the player clicks the replay game button. When the player clicks the replay game button it simply:

function newGame():void
		{
			init();
		}

It calls the init(); and the game resets it's. Unfortunately after this is done the button won't work. I click it and the visibility stays off. I've traced it and the button still works.

Response to: Math.random to pick player turn Posted December 30th, 2013 in Game Development

OOP is your friend, friend!

Thanks for all your input! Yeah this game was made 6 months ago before I started learning OOP. And even now 6 months later I am struggling to learn it haha Still need to learn about Arrays as well. I will continue to work at it :)

Response to: Math.random to pick player turn Posted December 29th, 2013 in Game Development

choosePlayer();

Just like you call Math.random(). "function foo():void" is just naming and defining the function, it doesn't actually do anything. Just place that line in the constructor or something.

Awe man do I feel dumb... Of course that worked....

Thank you for your help as always