Be a Supporter!
dynamic variable name Posted October 18th, 2010 in Game Development

Is it possible to change the name of a variable while the program is running

I want to reference 21 different variables all with names like

Ingredient1, Ingredient2...Ingredient21

how (if I can) would I make it so that I can reference them all by using a for loop and just changing the number part of the variable name

Response to: setChildIndex index out of bounds Posted October 18th, 2010 in Game Development

awesome that worked :) thanks


I have this code on the stage:

addChild(redPlayer.ingredientContainers)
;
setChildIndex(redPlayer.ingredientContai ners,1);
redPlayer.drawCollectBoxes(counting)

it works perfectly, however I want the top two lines to be in the drawCollectBoxes function which is in an external class called Player

when I try to just copy and paste into the function it looks like this:

public function drawCollectBoxes(counting:int) {
addChild(ingredientContainers);
setChildIndex(ingredientContainers,1);

ingredientContainers.gotoAndStop(countin g);
ingredientContainers.x = 650 + ((ingredientContainers.width + 10) * counting);
ingredientContainers.y=475;
}

which gives me the error: The supplied index is out of bounds.

so I tried making the second line setChildIndex(ingredientContainers,0); instead which gets rid of the error but now it's not putting it on the lowest index (since objects drawn after it get put underneath it)

I don't understand why this doesn't work and would appreciate help

Response to: addChild to stage from external .as Posted October 1st, 2010 in Game Development

I'm not sure I quite understand what you mean. You are correct, it is not in the document class and it is an .as file creating a class that will manage the tiles.

But when you say I addChild the Tiles to the manager do you mean the one that creates the tiles (which would be the document class) or the one that defines it's parameters (which would be the Tile class) or the one that I'm creating this function in (which is a class called Draw)

and no, there are no errors, it's just not doing something it should be


I've created a function that works on the main stage and I am trying to transfer it to an external class to make it an easily reusable function.

When I run it however, everything works except for the fact that it doesn't put anything on the stage as it should. All the info it needs is there it's just not putting it there.

Therefore I conclude that I am using the addChild(); incorrectly

here is some of my code if needed:

public function drawBoard(i:int, j:int, tiles:Tile, boardArr:Array, stageBoardArr:Array):void {

if (boardArr[i][j].types==1) {

var straightShapes:StraightShape = new StraightShape();
stageBoardArr[i][j]=straightShapes;

addChild(stageBoardArr[i][j]); //this is the problem area I think

stageBoardArr[i][j].y = (tiles.positions.coX * tileSize) + tileOrigin;
stageBoardArr[i][j].x = (tiles.positions.coY * tileSize) + tileOrigin;
stageBoardArr[i][j].rotation=-90*tiles.o rientations;
}
}

Response to: arrays in functions Posted September 27th, 2010 in Game Development

I'm initializing it outside the for loop with all the other variables on the main class then adding the second dimension like this:

for (i = 0; i < boardSize; i++) {
boardArr[i]=new Array(boardSize);
stageBoardArr[i]=new Array(boardSize+1);
for (j = 0; j < boardSize; j++) {

then in the j for loop I call the function

I figured I could initialize it in the class that the function is defined in but then it won't have a bunch of information that it needs which it gets (and needs to get) in the main class

arrays in functions Posted September 27th, 2010 in Game Development

how do I read a 2D array that already has stuff in it's cells into a function

this is the function call which is inside nested for loops which increase i and j by 1

drawing.drawBoard(i,j, tiles, boardArr, stageBoardArr);

and this is the actual function

public function drawBoard(i:int, j:int, tiles:Tile, boardArr:Array, stageBoardArr:Array):void {

//working code that uses the arrays like this: stageBoardArr[i][j]=straightShapes;
}

this however is not working and I'm fairly certain it's because I don't know how to read in arrays properly

Response to: removeChild error Posted September 24th, 2010 in Game Development

isn't that just getting rid of the tile display object that was just created that just happens to have the same parameters as the point in the array?

Response to: removeChild error Posted September 24th, 2010 in Game Development

then I don't know what the parent would be, as far as I know it doesn't have a parent

removeChild error Posted September 24th, 2010 in Game Development

I place a group of movie clips with random types (different shapes on a square) in a grid formation The code for placing the movie clips is this (this is in two for loops):

if (boardArr[i][j].types==1) {
var straightShapes:StraightShape = new StraightShape();
addChild(straightShapes);
straightShapes.y = (tiles.positions.coX * tileSize) + tileOrigin;
straightShapes.x = (tiles.positions.coY * tileSize) + tileOrigin;
straightShapes.rotation=-90*tiles.orient ations;
}
if (boardArr[i][j].types==3) {
var lShapes:LShape = new LShape();
addChild(lShapes);
lShapes.y = (tiles.positions.coX * tileSize) + tileOrigin;
lShapes.x = (tiles.positions.coY * tileSize) + tileOrigin;
lShapes.rotation=-90*tiles.orientations;
}
if (boardArr[i][j].types==5) {
var tShapes:TShape = new TShape();
addChild(tShapes);
tShapes.y = (tiles.positions.coX * tileSize) + tileOrigin;
tShapes.x = (tiles.positions.coY * tileSize) + tileOrigin;
tShapes.rotation=-90*tiles.orientations;
}

the movie clips are the objects being created and this works perfectly. However, later on I try to get rid of some of the movie clips from the stage. The code I tried to use for that is this:

for (var m:int = boardSize - 1; m > 0; m--) {

if (boardArr[m][1].types==1) {
removeChild(straightShapes);
}
else if (boardArr[m][1].types==3) {
removeChild(lShapes);
}
else if (boardArr[m][1].types==5) {
removeChild(tShapes);
}
}

this goes up a single column in the grid and should remove the tiles from the stage depending on each type and it does this (sort of) until it tries to remove more than one of the same type. So if it finds and removes an lShapes it doesn't error until it tries to remove another lShapes and then it gives this error in the output:

Error #2025: The supplied DisplayObject must be a child of the caller.

So I am assuming that this means it thinks all lShapes have been removed and thinks I'm trying to remove something that doesn't exist but there are other lShapes on the stage.

I am at a loss as to what to do about this. I hope it was clear enough for someone to help out

Response to: Dynamically Created Buttons Posted September 17th, 2010 in Game Development

Ohhhhh :)

Awesome, thank you very much

Dynamically Created Buttons Posted September 17th, 2010 in Game Development

I have a for loop that creates 3 buttons and places them on the stage. Here is the code for that:

for (i = 1; i < 6; i = i + 2) {
var topArrows:indicatorArrow = new indicatorArrow();
addChild(topArrows);
topArrows.y = (boardArr[0][i].positions.coX * tileSize) + tileOrigin - 60;
topArrows.x = (boardArr[0][i].positions.coY * tileSize) + tileOrigin;
topArrows.rotation=180;
}

most of this code is just saying where and how it's put on the stage. This code works in that regard.

Then I have code later on that tries to use the buttons so that whenever your mouse rolls over the button it does something. The trace is just testing to see if it works. This is the code for that:

topArrows.addEventListener(MouseEvent.MO USE_OVER, moveExtra);

function moveExtra(e:MouseEvent):void{
trace("GOOD LORD THERE'S A FISH!!");
}

This only works for the last button created. The first two buttons that the previous code made do nothing when I put my mouse over them. I would like all 3 buttons to do the same thing and don't know why they aren't.

Help is very much appreciated :)

Response to: Famous Last Words Colab Posted August 11th, 2009 in Game Development

At 8/9/09 12:05 PM, pikmints wrote: You just aren't going to do it?

Unless I get some more movies, what I have now just isn't going to cut it

Response to: Famous Last Words Colab Posted August 9th, 2009 in Game Development

Well, this is disappointing. The new deadline has gone and passed and I have not recieved a single new submission. Unfortunately 3 of them is not nearly enough to be sufficient so unless I get a sudden flurry of late ones I guess this colab is officially dead.

Response to: Famous Last Words Colab Posted August 5th, 2009 in Game Development

I have recieved that one yes.

It is one of only 3 I have so far. The deadline is only 3 days away I hope I'll be getting more than just that soon.

Response to: Famous Last Words Colab Posted August 1st, 2009 in Game Development

no, it's not you've still got a week.

Response to: Famous Last Words Colab Posted July 18th, 2009 in Game Development

Nooo, it's just been extended. Hopefully people are taking this time to improve their peices.

Response to: Famous Last Words Colab Posted July 9th, 2009 in Game Development

Alright, well...since I only got 3 submissions I guess I don't have much choice but to extend it a month. However this will put us in competition with the Power of Three stuff and that might over shadow us. But those who need some more time you have a month, those who want to join, you have a month and those who submitted already you can do some more work on your part to perhaps make it better.

NEW DEADLINE: AUGUST 8th

Response to: Famous Last Words Colab Posted July 7th, 2009 in Game Development

Ok, deadline's tomorrow and I've only got 2 submission so far

Response to: Famous Last Words Colab Posted July 2nd, 2009 in Game Development

At 7/2/09 12:22 AM, Fiziks wrote:
Fast-Food Drive Thru guy says 'Would you like fries with that?" In that muffled microphone vo...

Umm, no. Since in the rules it says you need to use the lines in the list and that is not one of them.

Response to: Famous Last Words Colab Posted June 29th, 2009 in Game Development

At 6/29/09 12:02 AM, ZanKeeper wrote: hey tygerman, is there any way we could extend the deadline by at least week? It seems a lot of people could use it. including myself. At least two people are having email problems, and one person wants to join but he just found the thread. It would be a GREAT help to a lot of people, and I bet a million bucks the collab would come out looking a lot better if we did this.

Alright, you have until July 8th. But those of you who do not need an extension please send it to me on the first. Remember, the sooner I get the submissions the sooner it'll be out.

Response to: Famous Last Words Colab Posted June 28th, 2009 in Game Development

At 6/28/09 05:12 AM, jayeshepherd93 wrote: no problem now, i used outlook express instead of hotmail and it worked

I don't think it did as I havn't gotten anything yet

Response to: Famous Last Words Colab Posted June 27th, 2009 in Game Development

At 6/27/09 09:33 AM, jayeshepherd93 wrote: windows wont let me send my file, can i send it to you over MSN?

If you must, just add my e-mail and tell me what your MSN name is so I don't ignore it because I don't know who you are

Response to: Famous Last Words Colab Posted June 25th, 2009 in Game Development

At 6/25/09 09:57 PM, Tygerman wrote: Six weeks left to submit!

I'm sorry, that's totally supposed to be 6 days!! not 6 weeks

Response to: Famous Last Words Colab Posted June 25th, 2009 in Game Development

Six weeks left to submit!

And don't be too worried about extensions there will be some leeway time for me to put it together and make the menu etc etc. and I need to know who I'm putting in it before I can continue.

As long as not everyone takes advantage of the extension some of you may have some more time.

Oh and keep in mind if you do submit on the deadline there's probably a better chance of you getting in since I'll be making the menu as soon as I get a bunch on that day.

Response to: Famous Last Words Colab Posted June 22nd, 2009 in Game Development

At 6/22/09 04:53 PM, UndergroundSound wrote: Just a thought, action script 3 or as 2?

If you absolutely have to please use Action Script 3

Response to: Famous Last Words Colab Posted June 22nd, 2009 in Game Development

At 6/21/09 11:25 PM, chillychubbs wrote: sorry for double post but, I was trying this out, and the idea, of it is that while this person is playing on his xbox, masterchief will walk in, *he'll be surprised* master chief will rip the bong, and say, does this taste funny to you?

it'll look better when it's smaller, and i need advice, I can't seem to put my finger on it but something is fucked up with the walking animation.

You may already be doing this but just make sure someone dies immediately after the line is said. And the walking sequence is weird I think because his legs are moving too fast for how fast he's moving foreward

At 6/21/09 03:20 PM, MochaMaster wrote: Can I join? :P

Anyone can join, just keep in mind I need your submission on July 1st which is in like 9 days

Response to: Famous Last Words Colab Posted June 19th, 2009 in Game Development

At 6/18/09 07:06 PM, sir5000 wrote: I'll try to get my part done this weekend.

What's the hurry? You have until July 1st. So please take that long and make sure it's really good.

Response to: Famous Last Words Colab Posted June 17th, 2009 in Game Development

At 6/16/09 05:16 PM, sir5000 wrote: If it's acceptable, I can do a "What does this button do?" or a "Pull the pin and count to what?"

Yes, totally, go for it. Either one, or both evennnnnn

Response to: Famous Last Words Colab Posted June 16th, 2009 in Game Development

At 6/16/09 09:01 AM, Deathamusesme wrote: Ok i got a problem. I have been working my ass of to get "Does this taste weird to you" work. All of my ideas turn out stupid and i wondered if i could get a new line. I got a great idea for "There's a duck?".

Yah, totally. Go for it :P There's no set thing for who gets what you can do all of 'em if you wanted :P