Recent posts by etrepum on Kongregate

Flag Post

Topic: Game Programming / Linkage Tutorial.

It’s probably worth noting that using release instead of press is very important if you’re opening up a new window, because press will get blocked by most pop-up blockers. I see that pretty often in games by people who probably should know better.

Here’s an example of URL linking:
<pre> on(release) { getURL("http://example.com/", "_blank"); } </pre>

The target "_blank" tells the browser to always open in a new window, which is usually the desired behavior for games.

 
Flag Post

Topic: Game Programming / Make a preloader [How to]

Yeah, it’s not really a bug and it would work fine, but it just wasn’t strictly correct so it makes for a bad example. If the whole point was to help people who want to stop preloading at less than 100% then it might have been worth mentioning because it sure wasn’t obvious.

If I were intending to play before the movie was fully loaded there would be some kind of explicit fudge factor (e.g. “at least level 1 loaded”) and probably an adjustment for estimated download speed. For the most part Flash games are small enough to where loading to 100% just makes the most sense. I would also make the display scale from 0-100% rather than just stopping at some arbitrary 64% or something.

On a more useful note, the technique for doing a preloader in AS3 with mxmlc is a lot different and totally undocumented (at least none that I found at first search). Keith Peters of Bit-101 managed to figure it out and came up with a solution that he blogged about here: http://www.bit-101.com/blog/?p=946

 
Flag Post

Topic: Game Programming / Make a preloader [How to]

To end that loop I wouldn’t use Math.round( ... ) == 100. I would check _root.getBytesLoaded() == _root.getBytesTotal() or use Math.floor( ... ). Using Math.round could fall through before the movie is fully loaded (99.5% rounds to 100%), unless that’s the intent.

 
Flag Post

Topic: Game Programming / [Resolved] Detecing distance to player?

I wouldn’t exactly say that AS3 doesn’t let you code like that anymore. It only lets you do it if you have a reference to some DisplayObject that’s in the hierarchy, but they do have a root property that can be used in much the same way. AS3 is pretty ridiculous in a lot of ways in that are really going to hurt the platform, but that’s another discussion for another day.

I’ve been professionally coding for a long time too, with about 8 years of Flash experience. I don’t use _root a whole lot myself, but it certainly has its uses. If you’re providing certain kinds of API to users, it makes a great default MovieClip reference because it’ll work for maybe 99% of most use cases with less work for the user. It’s also where you get URL variables, find out how big your SWF is and if it’s fully loaded, etc.

My real point is that people should do whatever they can get done quickest, provided that it works under the constraints they need it to. Games especially, because they’re usually relatively “throwaway” projects that are quite self-contained. Maybe Kongregate has some problems loading stuff, but only because they did it wrong. For the most part you just can’t load arbitrary movie clips and expect them to do the right thing (until Flash 9) because the Flash player simply wasn’t designed very well at the time. Unless of course you’re also advocating that everyone should use the same frame rate and that not using the same frame rate is bad because it won’t work in “complex situations”.

 
Flag Post

Topic: Game Programming / [Resolved] Detecing distance to player?

OT but MovieClip._lockroot makes those _root integration problems pretty much go away, if you can require Flash 7 or later. Using _root isn’t really all that evil if it helps you get stuff done faster, especially in a game…