Recent posts by MadBoat on Kongregate

Flag Post

Topic: Game Programming / "program arguments"

Originally posted by UnknownGuardian:

Yep, you’ll have to dynamically ask for the url of the midi file and retrieve data from it(is that possible without having to create a copy on a server/in game somewhere?)

as far as I know, no. but the file upload doesn’t need to be done at run time, so any solution is workable, including putting a constant in the code. just not pretty.

 
Flag Post

Topic: Game Programming / "program arguments"

hey guys, been a while, happy to be back programming AS.

my latest project is a MIDI to sheet music converter. I was hoping to be able to pass arguments to my code (at the very least, the file name of the MIDI file I want converted). how would you guys reccomend doing this?

 
Flag Post

Topic: Kongregate Multiplayer Games / [Battalion: Arena] New Units!

in my experience there is not enough love for infantry, so I would make the following suggestions

assume anything I omit is the same as strike commando
Alpine Infantry(dudes with skis and guns) Price:$130
Buffs: moves normally over mountains and hills

Motorcycle Commando Price: $150
Movement type: Wheels 6 spaces

 
Flag Post

Topic: Game Programming / AS3 quick question

it is for this reason that every class that I define with library linkages ends in a “C”

 
Flag Post

Topic: Game Programming / Spawning enemys?

Are you asking how I’d get them to appear off stage? I’d probably set their x and y values to some point outside the visible stage area (default stage values are (x 0-550, y 0-400). Then I’d write some code to control their wandering; eventually their aimless wandering would bring some of them into the visible stage area.

I would suggest asking a more specific question in the future

 
Flag Post

Topic: Game Programming / AS 3.0

Originally posted by jonathanasdf:

put it-a) on the frame, b) in an external file.

Go read the new as3 Shootorials!

http://as3shootorials.110mb.com/

Note: I did not create this. credits goes to Moly

thats a start, anyway. I use these forums, and occationally actionscript.org

 
Flag Post

Topic: Game Programming / AS 3.0

Originally posted by VoltageGames:

So what would be the exact code if my button was named BeginButton?

BeginButton.addEventListener(MouseEvent.CLICK, gotoFrame3);
function gotoFrame3(e:MouseEvent)
    {gotoAndStop(3);}

If you don’t know any code, why in God’s name are you doing this in AS3?

 
Flag Post

Topic: Game Programming / AS 3.0

Originally posted by Moly:
Originally posted by MadBoat:


I never bothered to read though those.

I’m hurt.

played shoot today, though, that was pretty cool.

Voltage, I never coded in AS2, so I don’t know exactly where you’re starting from mentally when you want to make a button, but AS3 is a big change from AS2. In AS3 you write a function with precisely 1 argument of type Event (or MouseEvent, KeyboardEvent, etc. etc. etc.), and then tie it to an event that can happen to a button. EX:

buttonName.addEventListener(MouseEvent.CLICK, dance)

function dance(e:MouseEvent)
{
    trace("dance dance!");
}

the easiest place to put this code is in the frame, so you open up the actions window, and pick the frame that the button is in. You’ll get a blank page. Slap this code in there and you should get a button that traces “dance dance!” when you click it.

Now, what do you mean when you say “save” the button? Do you want to save the code associated with it, so that it can be applied to other buttons, or you want to save the graphics you created for that button?

 
Flag Post

Topic: Game Programming / AS 3.0

he means a .as file.

Jon, I never bothered to read though those. Have you?

 
Flag Post

Topic: Game Programming / Textfield Weirdness (solved)

I HAVE CULPRITS!!!!!!!!!

The following properties(they’re actually getter/setter functions), when set, even if the new value is exactly the same, causes the new TextField’s height and width to quintuple.

scaleZ, z, rotationX, rotationY, rotationZ

all, you’ll notice, having to do with 3D animation. Probably an innocent mistake: I’m sure there’s some function that does not get called except when a display object is going to be in 3D animation that is doing the quintupling. And easy to fix too;


if (props[i].attribute("access")[0] == "readwrite")
			newF[props[i].attribute("name")[0]] = fieldParams[props[i].attribute("name")[0]];

becomes

if (props[i].attribute("access")[0] == "readwrite")
        if (newF[props[i].attribute("name")[0]] != fieldParams[props[i].attribute("name")[0]];
			newF[props[i].attribute("name")[0]] = fieldParams[props[i].attribute("name")[0]];

SO THERE!!! HAHAHAHAHAHAH SUCK MY NUTS BUG!!!

 
Flag Post

Topic: Game Programming / Textfield Weirdness (solved)

jon

You could have said “its more efficient”, and I would never have questioned it, you know :-j

the weirdness

Placing all the code in the same file as Moonkey does removes the problem for me, as does removing my XML-based cloning procedure. I don’t really know what this means, but I am going to venture a guess that one of the fields that my XML clone code tries to set is something you would never actually edit yourself, and this causes it to behave like this.

I’m curious if this happens for anybody else. I uploaded the files I’m working with; somebody mind giving them a try?. here’s the link. its in as3, made using flash cs4.

 
Flag Post

Topic: Game Programming / Textfield Weirdness (solved)

is there any reason to go one way or the other? in this case it’s trivial, but in more complicated classes the getter function will have a lot more to do than just check the argument for validity, and doing it like this saves you from having to set up those extra commands in the constructor.

 
Flag Post

Topic: Game Programming / Textfield Weirdness (solved)

I get the height of both TextFields as 100, before and after addChild. I don’t know exactly what JFunc.setCenter does, though.

just assigns x and y values to the data in the point (or two Numbers) supplied as argument(s). Taking it out doesn’t change anything for me.

You used the same code? instantiated it in the same place? Put it in the same kind of project?

jon

In using strings I’m emulating how Flash does it with events: MouseEvent.CLICK is a public static const String with value “click”, and the value is actually helpful in debugging, since you’re not passed the name of the constant, which is what we normally deal with. I used to put funny phrases in place of those events, which would give me a much needed chuckle when I was wrestling with some problem.

and stackStyle isn’t undeclared. its a getter/setter function associated with pvtStackStyle

as for the height problem (it also quintuples width, btw), without my wonky cloning code it works as expected. So if I put in a different means of cloning fieldParams values it ought to work. Also,

addChild(newF);//height 500
removeChild(newF);//height 100
addChild(newF);//height 500;

If that is compelling evidence of something, let me know.

 
Flag Post

Topic: Game Programming / Textfield Weirdness (solved)

That code is very unclear as to what it does any why it does it. I think that’s something that should be addressed first. As far as I can tell, all it’s doing is copying two specific groups of properties from fieldParams to newF.

Correct. fieldParams is a TextField whose properties I want all the TextFields I create with this function to emulate. I could do this with a battery of normal assignments, but I figured using describeType and modifying the XML like this was more condense and works for any object’s read-write properties.

iopred

Tried that before I posted. the default height for fieldParams is 100, and setting it to 50 reduces the height of newF by half from 500 to 250, exactly what you’d expect except for the quintupling

jon

Default setting of autoSize is TextFieldAutoSize.NONE, i.e. no resizing occurs. This is from a test file for a new module I’m adding, very barebones, so I’m fairly sure I haven’t inadvertently reset something else. Here’s most of the class…

public class SequentialVisualLogTC extends Sprite
{

public var fields:Array;
		
public static const STACK_HORIZONTAL:String = "Stack Horizontal", STACK_VERTICAL:String = "Stack Vertical", MANUAL_STACK:String = "Manual Stack";
private var fieldParams:TextField;
public var pvtStackStyle:String, placePoint:Point, extraOffset:Point;

public function SequentialVisualLogTC(fieldParamsA:TextField = null, stackStyleA:String = STACK_VERTICAL, extraOffsetA:Point = null)
{
	fieldParams = (fieldParamsA) ? fieldParamsA:new TextField();
	stackStyle = stackStyleA;
	extraOffset = (extraOffsetA) ? extraOffsetA:new Point();
	fields = new Array();
	placePoint = new Point();
}
public function get stackStyle():String
	{return pvtStackStyle;}
public function set stackStyle(newS:String)
{
	switch (newS)
	{
		case STACK_HORIZONTAL: case STACK_VERTICAL: case MANUAL_STACK:
			pvtStackStyle = newS;
			return;
	}
	throw new Error("Invalid value for stackStyle!");
}
public function addEntry(text:String)
{
	var newF:TextField = new TextField();
	
	var props:XMLList = describeType(newF).accessor;
	for (var i:int = 0; i < props.length(); i++)
		if (props[i].attribute("access")[0] == "readwrite")
			newF[props[i].attribute("name")[0]] = fieldParams[props[i].attribute("name")[0]];
	props = describeType(newF).variable;
	for (i = 0; i < props.length(); i++)
		newF[props[i].attribute("name")[0]] = fieldParams[props[i].attribute("name")[0]];

	newF.text = text;
	JFunc.setCenter(newF, placePoint);
	addChild(newF);
	fields.push(newF);
	switch (stackStyle)
	{
		case STACK_HORIZONTAL:
			placePoint.x += newF.width + extraOffset.x;
			placePoint.y += extraOffset.y;
			break;
		case STACK_VERTICAL:
			placePoint.y += newF.height + extraOffset.x;
			placePoint.y += extraOffset.y;					
			break;
	}
}

and the instantiating code, existing on frame 1 of an otherwise-blank project

import SequentialVisualLogTC;
import flash.text.*;

var templateField:TextField = new TextField();
templateField.text = "Banjo";

var log:SequentialVisualLogTC = new SequentialVisualLogTC(templateField);
log.addEntry("Snake");
addChild(log);
 
Flag Post

Topic: Game Programming / Textfield Weirdness (solved)

run this code through your debugger, and I think you’ll find that on the addChild() command, the height of newF quintuples. This confuses me.

oh, and props is a TextField with all default values, except that props.text = “Banjo”.

public function addEntry(text:String = "Banjo strings")
{
	var newF:TextField = new TextField();
			
	var props:XMLList = describeType(newF).accessor;
	for (var i:int = 0; i < props.length(); i++)
		if (props[i].attribute("access")[0] == "readwrite")
			newF[props[i].attribute("name")[0]] = fieldParams[props[i].attribute("name")[0]];
	props = describeType(newF).variable;
	for (i = 0; i < props.length(); i++)
		newF[props[i].attribute("name")[0]] = fieldParams[props[i].attribute("name")[0]];
			
	newF.text = text;
	addChild(newF);

oh, and no, the scaling is all 1s, so thats not it. atm, “this” is an empty sprite.

 
Flag Post

Topic: Game Programming / omgbbqwtfpl0x gimme sum code pl0xxx

we have a code snippets thread?
1: link plzkthx?
2: sticky that shit, yo?

jon, I think your physics are wrong (not that I’m an expert), but let me point out something more fundamental. Dice are used as random number generators precisely because the physics governing them are so chaotic. If you’re trying to model them accurately, I think you’re setting yourself up for a world of pain. Find someone elses’ work, or just fudge it.

 
Flag Post

Topic: Game Programming / AS3 Placing movieclips inside a movieclip/sprite

get removed?

Yes. All the things that you see on the screen when you run your .swf are objects that are descendants(children, grandchild, etc.) of the stage. calling Empty.removeChild(Ship) means the Ship MovieClip is no longer a grandchild of the stage, Bullet is no longer a great-grandchild of the stage, and BulletEffects is no longer a great-great-grandchild of the stage, meaning you see none of them.

 
Flag Post

Topic: Game Programming / Just started AS3

what’s your coding background?

 
Flag Post

Topic: Game Programming / AS3 Placing movieclips inside a movieclip/sprite

Yes, that will work fine. You’re likely already adding MovieClips within other MovieClips; your document class is required to be a MovieClip, so whenever you add a library-defined movieclip to the drawing area you’re adding a MovieClip to a MovieClip.

 
Flag Post

Topic: Game Programming / Confused, referencing a var from another as file AS3

(shrug) when something should work but doesn’t I typically keep rewriting it in different ways and different places until it does.

 
Flag Post

Topic: Game Programming / Confused, referencing a var from another as file AS3

const and defining it later didn’t work either?

try this maybe?

public static const letterArray:Array = new Array("a", "b", "yadda yadda yadda");
 
Flag Post

Topic: Game Programming / Confused, referencing a var from another as file AS3

I’m not sure if this will help or not, but you can always explicitly include your document class in wordTile. It won’t hurt anything.

instead of a static var, use a static const, or put the line that assigns the static array the array of letters into your document class’s constructor. I suspect the compiler isn’t actually executing the assign command, though why it isn’t spitting some compiler error at you I have no clue

 
Flag Post

Topic: Game Programming / Websites Flash vs. Javascript

There aer quite a few reasons why JS is better than Flash on a website, but itdepends a lot on what you’re actualyl trying to do with it. In general I can think of 5 or 6 reasons you’d usually use JS on a site instead Falsh, and I was gonna just list them all here, but I don’t think half of them are even releveant to what tyou’re asking, so I didn’t bother.

Please do list (or link) them. The marketing guy is basically letting me make the decision, so I need to be informed.

If we’re just talking about banner ads like the ones at the top of this page, then the only reasons to use Flash for those is if you want fancy rollover effects and whatever, or if you need more colours than gif wil lsupport.

Right now, the marketing guy reports wanting “movement” for the front page, and I’m pretty sure the requests will stay about that modest.

But, remember that lots of animations and effects in flash will alg slowerr Pcs and put off potential customers if they happen not to have a decent enoughmachnie to keep up with things on the page.

computers lacking power or bandwidth or whatever is not a concern; the company’s product is sufficiently technical that the vast majority of people visiting the site are going to be engineers and will have plenty of power for a dinky flash animation. What’s more of a concern is if such people have or want the flash plug-in on their machine.

These all sound like compelling reasons to use JS… not what I’d hoped to hear, I’ll admit :-/

 
Flag Post

Topic: Game Programming / I HATE AS3 REGEXP

Frogmanex

have a look at labels

UnknownGuardian

hehe, oh thank you for that hearty chuckle, sir.

 
Flag Post

Topic: Game Programming / Utility Functions

no, I did not. although that begs the question, why is the default to use a strong reference? Surely if I have no way of accessing an object, I’ve either no more use for it or I’ve accidently dropped it on the floor and, by rights, it shouldn’t work anymore?