Be a Supporter!
Response to: Shooting enemies with arrays! Posted June 20th, 2010 in Game Development

try giving the bullets a unique name, as opposed to naming multiple ones "bull".

Response to: AS3 Inheritance Problem Posted February 11th, 2010 in Game Development

Humor me on this one. Make A dynamic.

Response to: What is going on inside HitTest? Posted February 11th, 2010 in Game Development

Or it could simply do it by pixels. Draw the MC as a solid black (with transparent as solid white), and if the pixel at (x, y) is black, hitting, if not, not-hitting. Since the rendering engine can already have something like that running, it's all a matter of a 'what is this pixel here?'

Response to: Flash filters : flag wave effect Posted February 10th, 2010 in Game Development

BitmapData and Perlin Noise.

Response to: as3 scope issue Posted February 5th, 2010 in Game Development

I know -- Quick fix in my post, A string (as well as int, uint, Number) are called Primitive data types -- in OOP, Primitive types are OFTEN passed as VALUE, not reference! The reason this is important is if you try to change it as if it's reference, it won't.

Double also, the reason this (your original code) didn't work is even though they were passed by value, but they were all passed to the same variable. By that, the same var is overwritten. Then when you reference that at the end, you simply get the most recent value.

Response to: Weird Flash Behavior (as3)(cs4) Posted February 5th, 2010 in Game Development

Flash isn't perfect, and it's by no means normal. So defiantly report your circumstances to Adobe and try to copy + paste it into a new FLA, see if that fixes the problem.

If you can replicate it, tell them how and you'll probably have fixed a bug. Woo!

Response to: Diagonal Tile-Based Collision Posted February 5th, 2010 in Game Development

What do you mean? I'm a little fuzzy on how the movement works... Is each tile a static state? And you can only move 1 tile at a time? If that's the case, just pre-program tile interactions. If it's a 'I'm only checking 1 tile' issue, have it resolve not just the current tile, but all tiles it's touching.

Response to: I Need A Mentor Posted February 5th, 2010 in Game Development

You can email me any questions (ssjskipp@gmail.com), and I'll probably send a whole explanation + example code.

For starters, try to understand the new Display List system, how to navigate + manipulate it, how depth works now, and of course, OOP (which isn't exclusive to Flash)

Response to: as3 scope issue Posted February 5th, 2010 in Game Development

I'd call you dumb, but I don't want to be mean (and also, it's most likley not the case at all). Because chances are, you just don't understand how Flash, or most OOP languages, store data.

First off, yes, don't declare the function in the for loop. That'd just be silly. It's like telling flash to continually overwrite the reference to a function, ending with the last one.

Second, here's how your code should look:

var switchImg:String;

for (var i:Number = 0; i < colorArray.length; i++) { 
var c_sprite:MovieClip = new MovieClip();
c_sprite.x = colorX; c_sprite.y = colorY;
c_sprite.buttonMode = true;
c_sprite.addEventListener(MouseEvent.MOUSE_OVER,imgSwitch)
c_sprite.tmpSwitchImg = colorArray[i][1];
addChild(c_sprite);
trace (c_sprite.tmpSwitchImg);
}
function imgSwitch (event) {
	trace (event.target, event.target.tmpSwitchImg);
}

And here's why:
When you say 'switchImage' is something, then Flash says, "Okay. Let's set this. The variable 'switchImage', which there is only one of, will point to the data location colorArray[i][1]."
So, every time you change switchImage, it'll change where the data is pointing. Which is why you get the last element.

Objects are stored in 1 place of memory, then every time you say "this = some object", this doe NOT become a copy of that object. It becomes a pointer. And when you then look at 'this', you are given that 1 place of memory.

So, what you need to do, is STORE that place of memory in some object. Since you're wanting to retrieve this data when you roll over a sprite, it just made sense to store it on the sprite. Which I changed into a MovieClip, since Sprite is NOT a dynamic class (you can't just set random parameters onto a Sprite.).

Then, once you roll over a sprite, the event function will be called (and passed a reference to the target of the event), which you can THEN use to target the part of the 2D array (who's pointer is stored in the same piece of memory as the c_sprite)

Response to: Flash Freeware Posted February 4th, 2010 in Game Development

Flash trial is 30 days. Try that first.

Response to: [AS2]drop game Posted February 2nd, 2010 in Game Development

Ask yourself what it means to have a block touching:
Is there an object above, below, or at my sides?
Then the question is:
What object is it?

So, the easiest way to do this is 4 hitTest, testing against any object. (hitTest + shapeFlag). If that evaluates to true, then we need to do something a bit more precise. So, loop though all the blocks:

for (var i in _root){
//i will = all methods of _root. That includes MovieClip names.
trace(_root[i]);
}

There's tons of methods. But the important thing here (and probably the answer to your question) is that you can use strings to access MovieClips. That's important because a string can be a variable. So, you can do:

for (var i = 0; i < 10; i++){
trace(_root['Block_'+i]);
}

Which will trace every MovieClip named "Block_0" to "Block_9", inclusive.

Response to: Make movieclip go to a random frame Posted January 31st, 2010 in Game Development

Here, I forgot the AS2 syntax, this is a better version (independent on the number of frames an MC has):

[target].gotoAndStop(random([target]._totalframes)+1);

Of course random has been deprecated, but it's still there. Just like AS2.

Response to: Actionscript3, Problem: Mouse Click Posted January 31st, 2010 in Game Development

Probably because you don't add the tower in the constructor. It's not on the stage so it doesn't have a stage property.

You need to pass, in the constructor, a link back to the stage, OR have a static constant link on a different class (probably the Main/Document class).

Response to: Actionscript3, Problem: Mouse Click Posted January 31st, 2010 in Game Development

That's what I just said.

Putting the event ON the tower will only broadcast when you click the tower.

If you want it to broadcast when you click ANYWHERE, add it to stage rather than "this".

Response to: Make movieclip go to a random frame Posted January 31st, 2010 in Game Development

[target].gotoAndStop(random([target]._totalframes);

Where [target] is the reference to the MC.

Response to: Weird Error!? Posted January 31st, 2010 in Game Development

Lemme see the line where you declare the function in LogoObject.

Chances are, it's set as private.

Response to: Actionscript3, Problem: Mouse Click Posted January 31st, 2010 in Game Development

this.addEventListener(MouseEvent.CLICK, shoot);

That means when you click the object [this] is talking about, it'll call the event. If you want it to work when you click *anywhere*, do stage.addEventListener

Response to: Get internet connection speed?[AS2] Posted January 29th, 2010 in Game Development

Don't really need to test for their connection with a small file.
Just while your flash app is loading, use the getBytesLoaded, take it at 1 frame, and again at another. Now you have a change over time. Math.

Response to: AS2 - A star algorithm Posted January 14th, 2010 in Game Development

Most of the time, A* is implemented as a function that takes a 2D array, a start row and column, and end row and column. It then returns an array of row and column pairs in some order (from start to end or end to start) of the "best" path.

The 2D Array is a numeric grid of positive values where 0 is impassable (walls, water, etc), and the higher the number the higher the 'cost' (1 is like grass, 90 is fucking lava, you get it).

That's pretty much all you need to know about it... Sometimes they have options for diagonals or not. Just search AS2 A Star and I'm sure you'll find them.

Response to: Destructible Landscape Ala Worms ? Posted December 28th, 2009 in Game Development

He was probably just trying to sound smart since he's read the tutorial for N.

But yeah, BitmapData, call 'draw' and create your landscape, and destroy them. Then getPixel32 to identify points like you said for slopes (using bitwise color mask, you can filter out alpha and non-alpha pixels to get borders), and you're golden.

Response to: Free PHP hosting Posted November 16th, 2009 in Game Development

Or XAMPP!
http://www.apachefriends.org/en/xampp.ht ml

Response to: ??Key Press instead of Key Down?? Posted November 12th, 2009 in Game Development

You need to learn how to understand programming logic. But here's an answer for you:
Let's see. We know when a key is being held down or not. But what we need to do is run an action ONLY ONCE when they press it, not EVERY time as they hold it. So, how can we transform the information of "Key is down" to "Key is down and I haven't done anything yet"?

Well, let's see. A Boolean is a true/false value. So if you make a "flag" like so:

onClipEvent(load){
var pressFlag:Boolean = false;
}

Then the the following logic:
Is the key down?
Yes -> Is 'pressFlag' true?
Yes -> Yes -> Then I've already run the press action. Don't do anything.
Yes -> No -> Then I should act like they 'pressed' the key. And I should set 'pressKey' to true, since I've ran the press actions.
No -> Then I should set 'pressFlag' to false, sine they're not pressing the key at all.

In code, that'd be:

if (key is down stuff){
if (pressFlag != true){
//Do some action
pressFlag = true;
}
} else {
pressFlag = false;
}
Response to: New Platform Engine Fx Posted November 2nd, 2009 in Game Development

Did you get the idea to use the convolution filter from here;
http://www.unitzeroone.com/blog/2006/03/
28/flash-8-example-3d-bumpmapping-using-
filters-source-included/

?

Response to: AS3 questions Posted October 27th, 2009 in Game Development

How could you not understand classes? You've been working with them since you started playing with AS2, really.

In AS2, Key is a static class that had some static constants for keycodes, as well as some static functions like isDown. MovieClip itself is a class that has a bunch of (thanks to extension) properties like x, y, rotation, alpha, etc.

In AS3, this is much more obvious and accessible. There's a definite chain of inheritance and it makes sense.

A DisplayObject has thee framework for position, transformation, and the basic functions like hitTest and whatnot. A Sprite is a DisplayObject with 1 frame, and is a DisplayObjectContainer. A MovieClip is a Sprite with multiple frames and dynamic properties.

So, when you right click your bullet in the library and hit 'Export for ActionScript', did you notice that instad of Linkage Name, it has a Class name? Why not try to define that class name, and create a seperate .as file (of the same name), save it in the same folder as the fla, and define the insides as a class.

There you go. Classes.

As for your problem, you really need to understand how flash works...

Also, Gust'll probably be mad at me for saying thing, did you ever think to look up the docs? "_root" is still there, now it's just "root'.

Response to: Eval doesn't work :S Posted October 27th, 2009 in Game Development

And if you want to refer to an instance name with a variable part (IE: bullet0, bullet1, bullet2, ...), you can use this method of accessing object params:

object['paramname'];

so

myMovieClip['bullet'+i];

Where i is a variable. Same as writing (if i were 0)

myMovieClip.bullet0

Response to: AS3: Point of proper getter/setters Posted September 30th, 2009 in Game Development

First off, the PHP-esque variable names don't cause errors (at least in AS3). You can have a sigil if you want (_, $, @, etc.) as long as they're not keywords or operators.

To answer your question a bit more, part of it is for documentation, and part of it is for when you deploy these packages.

If you're writing a class that other people do NOT know the inner working of, having values set to 'public' means they can access them directly. To people downloading + using these classes, that means that these are values you're SUPPOSED to modify. Confusing.

As for documentation, when you document your class, you'd have to specify that in order to modify this property, you must use this fucntion. Which, in a large class with a lot of things going on, can confuse and expand the documentation and usability.

In any sense, if you're the ONLY person using the code, or it's not a big thing, then you can do whatever the hell you want. I mean, you can even make a class specifically to handle changing values in other classes. Not the best method, but one that'll work. It really jsut comes down to what you like to do and what works best.

Response to: AS3: Point of proper getter/setters Posted September 30th, 2009 in Game Development

There's a lot of uses, but simply managing data in and data out AREN'T one of them. If you're returning and setting the same variable, and nothing else, there's no use for using a getter or setter.
HOWEVER
Say something was dependent on that value, or there's variables that are related to the one in question. A translation system. Take temperature for example. Say you wanted a class to work with temperature. You can have:

public class Temperature {
	private var $Celcius:Number;
	private var $Farenheit:Number;
	private var $Kelvin:Number;

	public function Temperature(degreeFarenheit:Number):void {
		$Farenheit = degreeFarenheit;
		$Celcius = //convert F to C
		$Kelvin = //Convert F to K
	}

	//Setters, however, change the others
	public fucntion set celcius(newValue:Number):Number {
		$Farenheit = //Convery newValue to F
		$Celcius = newValue;
		$Kelvin = //Convert newValue to K
	}
	
	public fucntion set farenheit(newValue:Number):Number {
		$Farenheit = newValue
		$Celcius = //Convery newValue to C
		$Kelvin = //Convert newValue to K
	}
	
	public fucntion set kelvin(newValue:Number):Number {
		$Farenheit = //Convert newValue to F
		$Celcius = //Convery newValue to C
		$Kelvin = newValue
	}

	//Getters are the same, since we stored the data
	public function get celcius():Number {
		return $Celcius;
	}

	public function get farenheit():Number {
		return $Farenheit;
	}

	public function get kelvin():Number {
		return $Kelvin;
	}
}

That's a bad example, the the useful concept is there. You may come across (and probably will) an instance where you want to change something (say, a state like "fight" or "run'), and when you do that you want the class to do something more (like, play an animation, or run a specific routine).

Same thing with getters. Say you have a value that can be obtained from data in the class, but isn't explicitly there. You can run a function and return a value behind the scenes, but to the user you're simply doing:

this.angleToPlayer;
Response to: Diagonal scripting?! Posted September 25th, 2009 in Game Development

Everyone wondering why:

Unless you embed the fonts, you CAN NOT rotate or skew Dynamic or Input text field.

Response to: As 2.0 Help (deadline for school) Posted September 14th, 2009 in Game Development

when you target an object to apply a rollover function, or any of the 'on' functions, it's formatted like so:

target.onRollOver = function(){
//code
}