Thanks, Toothpaste for Dinner.
This is for anyone who’s having hair-tearing issues with working with binary data in Flash or Flex, or for those who want to be working with it.
Check out my first visual experiment with HaXe, an excellent new(ish) programming language that can compile to swf!
Remember back when you learned C? Way, way back in time? Well I do. When I recall my experience with C, I remember it being intoxicatingly fast and powerful. Kinda felt like mainlining into an artery of the machine: so much potential for incredible speed, but also horrendously dangerous and unforgiving.
I noticed today that the Flash game I’m working on has some odd framerate quirks, and I was wondering if anyone else has noticed similar behaviour. I know that Flash’s framerates can be quite unsteady at the best of times, but this is not the issue I’m having (at the moment).
I’m using Flash CS4, and the fps is set to 30. However, when I run it normally (within flash using “Test Movie”) I get a frame rate of 19.95 fps or so, and it’s quite steady. When I run it externally, with the flash player or in a browser, I get pretty much exactly 30 fps.
The frame rate in Flash remains at about 19.95 even if I bump up the fps to 60, even though this is faster fps is reflected correctly when it’s run externally. The game is a simple tile-based puzzle game, and is certainly not CPU bound. When running inside Flash, it’s using about 13% of the CPU.
When I set the framerate to, say, 10 fps, it runs at the correct speed everywhere.
Anyone have similar experiences with Flash? Any advice?
When constructing custom BitmapData subclasses which have been defined in the Flash Studio (such as MyFancyBitmapData), it turns out that you don’t actually need to pass the correct width and height of the bitmap. The MyFancyBitmapData class completely ignores its two (required) constructor parameters, and uses hard coded ones.
So don’t bother meticulously violating DRY principles when creating these things dynamically. You can pass any integers you like, including zero or negative one, but I particularly like using NaN because it makes it clear that you’re not even trying to supply a number that could possibly be interpreted in any meaningful way (even if that’s a tad passive aggressive…)
// e.g. var myBitmapData:BitmapData = new MyFancyBitmap(NaN,NaN); trace(myBitmapData.width + ", " + myBitmapData.height); // outputs: 45, 45
It seems a bit ugly to me that the generated BitmapData subclasses require their parameters. I really do think they should be optional at the very least, and ideally, illegal.
Hope this saves someone some time.
Note to self: shisha is tobacco. Tobacco is poisonous. Never forget.
Ever wanted to draw a curve directly through any number of points with the Flash Graphics class?
Here’s a class that will do that for you. It uses a “Catmull-Rom” spline (named after its inventors), which draws directly through any number of points.
It’s not a spectacular or pretty looking curve. It’s very “dowdy”, and somewhat ugly, but it doesn’t make wild swinging curves like many other equations. This humble quality makes it really good for situations where it’s important that the curve stays pretty close to the control points.
BlackScreen is an extremely simple utility application that displays a full screen of blackness for you.
I created it because I wanted to be able to easily see where my screen was dirty without shutting down or sleeping my computer. It could also be useful if you want to quickly hide what’s on your screen from beady prying eyes.
It’s built on AIR, so it’s cross-platform as long as you have Adobe’s runtime installed.
(Safari users should disable Open “safe” files after downloading in Safari’s preferences before downloading.)
For the love of god, play this game!