Posted by

The New AS3 Bible

by

Huge news, everyone! The long-awaited (by my editors) fully-updated, fully-revised, fully-correct, fully-awesome second edition of the ActionScript 3.0 Bible is finally here, after a year of hard work. Now, I don’t have a copy yet, but apparently some of my reviewers just got their copies, and I can’t wait to see what they have to say about it. More, more, more copies should be hitting shelves now or real-soon-now.

I’ve oh-so-hastily put up a rather revolting home for the book right here at http://www.actionscriptbible.com/. There are a few small parts missing right now, and it’s ugly, so bear with me.

In any case, whether you loved or hated the last edition of the Bible, I really urge you to at least give this edition a try. I’ve completely overhauled it, rewriting hundreds of pages, and adding onto it so that it’s bleeding-edge fresh for Flash Player 10.1. How fresh is this ish? This fresh, BOOM:

  • Vectors: COVERED
  • 3d: YES
  • Pixel Bender: YOU BET
  • Flash Text Engine: FER SURE
  • Text Layout Framework: IN THERE
  • Multitouch: SO MANY TOUCHES
  • Globalization: MAIS OUI!
  • Accelerometer: HELL YAH
  • Color Correction: SURE!

What else? I’ve toiled to give you the best way to play with example code ever! And by toiled I mean “stood on MASH’s back!” Because every example in the book (save a few that need HTML features or looser security) uses the amazing Wonderfl service! First off, it’s never been easier to run example code. This is what an example looks like:

See, every example has a URL right next to it. This, Example 36-5, links right to http://actionscriptbible.com/ch36/ex5. So if you have the book open, just type in the URL and boom! You’re looking at the code, the example, you can download it, edit it, and best of all participate with the whole world in forking the code! No FTP to hit, no ZIP to download (though that’s still provided if you want), no software to setup… I’m really happy about this part of the book.

Get this; I’ve even put in a UMLesque table of contents, so you can find the chapter for the right class in a glance.

I know most of you readers are advanced AS3 developers and don’t need an introductory text. But if you need to get up to date with the latest Flash Player 10.1 features, or you want a good reference; if you’re coming from JavaScript or PHP or C# or Java; I shamelessly and unsurprisingly recommend my own book. Get it now at Amazon.

Killing 3D Transforms

by

Here’s a quick tip. If you’ve ever dealt with 3D in Flash Player 10+ you’ll know that DisplayObjects in 3D in Flash Player are bitmap-cached; only the bitmap representation is transformed in 3D. Recently I was working on a site where objects landed on the stage, but after landing, they appeared really muddy, which was obvious when you looked at the text they contained. Even though they were completely flat, they were still using bitmap proxies! Not great.

Turning a DisplayObject into a 3D DisplayObject is as simple as assigning a value to its rotationX, rotationY, rotationZ, or z properties. But how do you turn it back? I tried giving all these properties a value of 0, but after their animations completed they were already 0. An object at z=0 still renders in 3D, using bitmap caching. Setting these values to NaN was no better.

The solution I found is to null out the 3D transformation matrix and assign a 2D transformation matrix. This can be accomplished like so for a DisplayObject named sprite:

var matrix:Matrix = new Matrix();
matrix.translate(sprite.x, sprite.y);
matrix.rotate(sprite.rotationZ);
sprite.transform.matrix3D = null;
sprite.transform.matrix = matrix;

In this code I simply drop the transformations that are inapplicable to 2D space. This is fine when your object is already coplanar with the stage.

Anyway, quick tip if this ever had you scratching your head too.

iPhone Project Keeps Appearing in iPad Simulator?

by

Hey guys, this is a quick thing I’ve run into while using the beta of the iPhone OS 3.2 SDK. If you create an iPhone project for iPhone OS 3.2, you might notice that every time you launch it, it appears in the iPad simulator instead of the iPhone simulator.

If this happens to you, it’s because 3.2 isn’t available on the iPhone yet, so regardless of your active configuration, the project has to run on iPad. For now, to fix this, you’ll want to roll your project back to iPhone OS 3.1.3 or earlier. Just go into your project info → Build Settings and set the Base SDK to iPhone Device 3.1.3 (or what have you). You’ll also want to make sure that SDK version is active in the Active SDK run settings.

I know this little fix is only going to be necessary for a short while, but if you were one of the 14 people wondering why this happens, there you go.

Tagged ,

Learn Yourself to Debug Good With XCode and Instruments

by

Hi! (Here Roger pretends it hasn’t been 100 years since his last posting and moves on swiftly.) So if you’ve been learning or practicing iPhone development, you might agree with me that there’s one topic that inspires a little FUD and that is covered a little sparsely by books — debugging. Between scary messages like EXC_BAD_ACCESS, uncaught exceptions deep in the guts of thorny disassembled framework code, crashes that don’t break into the debugger, and the direct interface to the gdb console, debugging in XCode can have a learning curve even if you know your way around a debugger. I’ve seen too many good men use NSLog() to debug, and it bugs me.

So here’s a few screencasts I found around town on debugging, that I wanted to share. Do yourself a favor and watch them.

First up, a series of two screencasts by Jeff LaMarche on debugging basics. I’ll reiterate, even if it starts out basic, you might learn something since it seems everyone uses the debugger differently. Part One, Part Two. Key takeaways:

  • Dude. Just drag the breakpoint out of the gutter to remove it. I’ve been right-clicking the damn thing my whole life. Sighhh….
  • XCode breakpoints are heckuv powerful. Use symbolic breakpoints, conditional breakpoints, and breakpoint actions wisely.
  • Single most important thing: Add a symbolic breakpoint on objc_exception_throw. Newer XCode builds have a menu item for this in Run→Stop on Objective-C Exceptions.

Next, a screencast on debugging EXC_BAD_ACCESS, which is raised when you access an object that has vanished into thin air, most likely because you over-released it. This screencast from Mark Johnson shows you how to debug these errors with Instruments and NSZombies. You’ll see how to generate a complete history of any object, from allocation and including every release or retain. You’ll also see how to find the objects of interest by enabling zombies (you know, after your object is completely released and freed it sticks around, undead). For those of you who see Instruments and aren’t quite sure what to do with it, just watching Mark use it is helpful. My takeaway was that it’s much easier and nicer to use Instruments than to enable zombies by hand.

Finally, here’s a nice tutorial by Owen Goss on using Instruments to find memory leaks. It’s also another good scenario which you can follow to help get your head around Instruments.

Bonus info: XCode 3.2 and later has the Clang Static Analyzer built in. This is a sweet tool that analyzes your code without running it (thus the static part). Just run Build→Build and Analyze and you’ll get a brutal report of how and where Clang thinks your code is totally sketchy. John Muchow shows you how here.

Anything that still baffles you about XCode/iPhone debugging? Care to add any other beginner debugging help? Hit the comments!

Balloono: Based on a True Story!

by

Balloono

Check out the latest ridiculous multiplayer chaos unleashed by those crazy, crazy test tube babies at IILWY, Balloono! I developed this game, but it wouldn’t exist without the awesome assistance of EJ, Ken, Daniel, and Charles. For taking it the last mile (or five) and adding lots of great art and polish, THANKS! Great work you guys! Oh yeah, and you’re cool too, Mark.

Keep coming back, ’cause I’m sure IILWY will be adding more levels and other bonus monkey jams! And hey, if you like the game, it couldn’t hurt to vote for it on Newgrounds, right?