Archive for Flash Programming

AIR iOS Memory Management Unavoidable

I’m still working on my IOS game and continually see it crash. Crash meaning it will just go black and back to the main menu. Soon I discovered that memory management is now more important than ever. If you think the garbage collector is working, it’s actually not. You’ve just been lucky that your computer didn’t run out of memory by the time it shut down.

When it comes to mobile there is no avoiding this, and at times its even harder than normal memory management. Everything you NEW you must null when you’re done. And that’s not enough, you also have to remove all listeners, dispose all bitmaps, null all sounds. Too bad, I wanted to avoid memory management, Objective C was a nightmare.

Learn how to change your code here:

Then afterwards, learn about putting Flash Preload Profiler into your projects:

Happy garbage-marking!!

UPDATE#1: I’ve had a lot of problems here, my game never cleans up its garbage even on the normal Flash player. Some movieclips never get cleaned up, the profiler says there’s 100 instances. And I nulled/delete/dispose/removeEventListener the crap of it. No luck yet.

UPDATE#2: I’m moving to Corona SDK. Bye Flash, I still need you for my day job.

Machinarium compiled with AIR 2.7 iPad2 only

Machinarium a Flash game compiled for iOS is making good sales and near #1:

Machinarium in iTunes

Unfortunately its for iPad2 only, and if you have iPad1 it won’t stop you from buying it which should greatly affect ratings. I almost pulled the trigger until I saw the starry thing saying iPad2 only, I doubt everyone noticed it, they were too excited. I asked Tom Krcha, an Adobe evangelist, what version and he tweeted back “2.7”. And from a CNET article it’s iPad2 only because of its high memory usage. Two things that I was very curious of, and I now understand the usefulness of Twitter. Apple get $1.50 per game sold, so hopefully Apple and Adobe will be best buds again.

Machinarium Cnet Article

Adobe will now have to compete with Corona. Corona stays in business and updates often because of their $350 a year fee, which will probably go up over time and success. Adobe is trying harder and funding itself with costly mid-year updates ala CS5.5. But mobile technology is changing so fast that they would probably end up charging a yearly or monthly fee just to keep up. Right now they are way behind in terms of capabilities, but this game is a good beginning.

Live editing XFL CS5.5 works!

UPDATE: DO NOT use it still buggy. A library item I had just kept getting corrupt all the time, no matter what. Weird!

After seeing so many bugs with CS5 I was hesitant to even try XFL. Today with CS 5.5 I finally gave it a spin and it actually works! What happens is that you can go into your folder just edit the image (or audio) in Photoshop then save it right there. It will update on the stage almost immediately, it’s pretty neat. My FLA was getting big at 100MB so it was a necessity to at least try it out. But there are two big catches!

#1 If you have a normal FLA already with tons of art and sounds, THEN you convert it to XFL, it will NOT save those art and sounds as their original files. For example if you had “bg1.png” in your FLA then convert to XFL format it will not be in the new XFL folder structure. It will be in DAT format in the BIN folder. You can only get it back if you right-click then import that file back. Any new assets you put in from then on will be okay. This will be a big headache for me since I have over 100 assets in my original FLA.

#2 If you have new files or move stuff around inside the library IDE, DO NOT live edit anything until you save. So say you moved (rename, delete etc.) “bg1.png” to folder “bg”, but you live edit “bg1.png” where it is now. Unless you save the FLA first it wont move to folder “bg”. So your edits won’t appear. So last tip, it’s safer to save your XFL first, then start live editing, just in case.

So when you decide to go to XFL format, my simple advice is to start in that format now. Lesson learned.

Initial test AIR3.0 RC1 for iOS

Just want to preface that I make simple 2D Flash games for iOS, so if you use it for other things you may have better luck or more need to upgrade. I usually download the latest beta or release candidate, so I got the latest one here. I already have a simple Flash game running fine with AIR2.6, tested on iPhone 3GS, iPod 4G and iPad 1G. So it still could be some new configuration issues I’m missing:

1) Loading screen still screws up. This has been there for a while, not sure why this is not noticed by Adobe. Loading screen looks fine then for 1 second it switches to squeezed portrait. In AIR2.7 it was worse, the screen would scale off. AIR2.6 also flickers, but at least you can start black for a few frames to skip the weirdness.

2) GPU and CPU seem to be working fine. In AIR2.7 CPU mode was totally screwed up. I do a simple rotationX, rotationY card-flip animation that seems to stutter more than in AIR2.6.

So again I only make simple 2D games at the moment, that don’t need any advanced stuff. I can easily stick with the old AIR2.6 with no problems since that still seems the most stable. I’m not sure why Adobe is just not noticing simple stuff when they release a build. Maybe they don’t have enough QA?

Weekend read of Robotlegs micro-architecture

My weekend read will be “Actionscript Developer’s Guide to Robotlegs. Robotlegs is an AS3 micro-architecture that supports MVCS style. As a minimalist adding more code bothers me but this thing had me at “robotlegs”. This funny name has roots in SmartyPants and Suspenders, all amusing and will probably conjure funny images while I’m programming.

I spent some time investigating different architectures. The most popular seems like pureMVC. While I see that it’s valuable for my resume, it may be overkill for the smaller games I’m making. Though I haven’t used it directly it looks like it will probably slow me down and force me to write bloated code.

Pushbutton is also there. It’s a component style architecture which seems simple and interesting, but the thing that turned me off was that their last blog was dated 2010. Which is definitely not a good sign.

Finally, I see that robotlegs has just released a book, which of course is a very good sign. I like how it says it will make things go faster and solve 80% of your problems with 20% extra code. Sounds like a great deal!

But before I delve into the book, I see there is a ton of references to “dependency injection”! Two horrible words together. First wow, I’m going to make my code more dependent, and on purpose. Then I’m going to “inject” it. So I’m going to make my code even more monolithic, can that really be a good thing? Hopefully I’m just misinterpreting the term. Hmm, I better start reading …