Grant Skinner

The "g" in gskinner. Also the "skinner".

@gskinner

AS3: Resource Management pt 2

ActionScript 3 has empowered Flash developers with faster code execution and a ton of API enhancements. Unfortunately, it has also led to the need for a much higher level of developer responsibility than ever before. In order to prepare and educate developers on how to deal with some of this new responsibility, I am writing a series of articles on resource management in AS3, Flex 2, and Flash 9. The first of these articles discussed the mechanics of the Garbage Collector in Flash Player 9. This article will focus on the implications some of the new features of AS3 have on resource management, and the potential headaches they could cause you even in simple projects. The next article in the series will introduce some of the new tools we have at our disposal to deal with these issues.

The biggest change in AS3 that affects resource management is the new display list model. In Flash Player 8 and below, when a display object was removed from the screen (with removeMovie or unloadMovie), it and all of its descendants were immediately removed from memory, and halted all code execution. Flash Player 9 introduces a much more flexible display list model, where display objects (Sprites, MovieClips, etc) are treated the same as normal objects. This means that developers can now do really cool things like reparenting (moving a DO from one display list to another), and instantiating display objects from loaded SWFs. Unfortunately, it also means that display objects are now treated the same as every other object by the Garbage Collector, which raises a whole slew of interesting (and possibly non-obvious) issues.

Continue reading →

Understanding the Delete Keyword.

In the comments of my previous post about how the garbage collector works in Flash Player 9, Cédric Néhémie asked a great question about why using delete on a property of a sealed (non-dynamic) class throws an error in ActionScript 3, and whether it will delete the actual object in memory.

There isn’t a lot of documentation on this topic, and what there is is hard to find, so much the following is conjecture and interpolation from related exploration, but I think it is fairly accurate. If not, please let me know in the comments – I don’t want to lead anyone astray.

My understanding is that the delete keyword deletes the actual variable definition, not just the variable’s value. This of course frees any reference it was holding, potentially freeing that object for garbage collection (as described in my previous article). It will not delete the referenced object from memory directly.

Continue reading →

AS3: Resource Management pt 1

I’ve been playing around with AS3 for a while now, and am really excited by its capabilities. The raw execution speed by itself will create so many possibilities. Toss in E4X, Sockets, ByteArrays, new display list model, RegEx, a formalized event and error model, and a few dozen other features for flavour, and you have a pretty heady brew.

With great power comes great responsibility, and this will be very true for AS3. A side effect of all this new control is that the Garbage Collector is no longer able to make as many assumptions about what it should tidy up automatically for you. This means that Flash developers moving to AS3 will need to develop a very strong understanding of how the GC operates, and how to work with it effectively. Building even seemingly simple games or applications without this knowledge can easily result in SWFs that can leak like a sieve, hogging all of a system’s resources (CPU/RAM), and causing the user’s system to hang (potentially even forcing them to hard reboot their computer).

Continue reading →

Types in AS3: ints not so fast, uints slow!

UPDATE: These findings are not relevant in more recent versions of the player. Please see this article for more recent results, and to run the tests for yourself.


Sho just posted a really interested article on why he won’t be using the int data type very frequently in ActionScript 3. Up until reading it, I had believed that as in other languages, there were large performance benefits to using ints and uints appropriately in AS3. Turns out that isn’t the case.

I did some quick testing on this, which confirm Sho’s assertion that int is only slightly faster than Number in ideal circumstances, but the results from uint were much more surprising.

Continue reading →

Mactel and Adobe, One Week Later

It has been about a week since I got everything set up on my new MacBook, and I thought I would write up a quick post to let everyone know how things are going with the new system.

Hardware setup

First, let me briefly describe my setup. For hardware, I have my new white 2.0ghz MacBook, with 100GB HDD and 2GB RAM. I connect it to a 23″ Apple Cinema Display at home, and a 17″ Sony LCD at the office with monitor spanning between the MacBook screen and the external monitor (ie. two monitor setup, not mirrored). I also use an external mouse/keyboard in both locations. I chose to keep the larger display at home because I tend to handle a lot of managerial / business stuff at the office, and do more intensive coding at home. As with all Macs, the MacBook does a perfect job switching between different monitors and peripherals, remembering resolutions and settings for every location. A docking station would be nice, but I can live with plugging in 3-4 cables (power, monitor, USB, audio) at each location.

Software setup

For software, the MacBook is running Mac OS 10.4.6. I have Flash MX, 2004, and 8 installed for Mac, as well as PhotoShop and the Mactel native Flash Player 8. Using Parallels virtualization software, I am also running Windows XP Pro SP2 with Flash 8, FlexBuilder 2 and the Flash Player 9 beta. I would definitely recommend reading the at least the Quick Start guide if you plan on installing Parallels VM – not all of the options are entirely straightforward.

Continue reading →

Adventures with Adobe and an Intel Mac – Part 1

I recently decided to purchase an Intel Macintosh for my main work system, despite there being no native binaries for the software that I use most often: Macromedia Flash and Adobe Photoshop. There was a few reasons I decided to take this plunge:

  1. My 12″ 1ghz Powerbook was far too underpowered to do daily work on, or even to use for training / presenting at conferences.
  2. I work at home, the office, and while traveling. I was sick of trying to synchronize 3 computers, and more than a little bit worried about overwriting the wrong file.
  3. There was no way I was going to shell out major coinage for a new powerbook that wasn’t using the newest processors.
  4. Bootcamp/Parallels should (more on that later) let me run Windows versions of the software I need when I require good performance.
  5. The new Macbook is just a ridiculously good deal in terms of price/performance/features, especially by Apple standards.

Continue reading →

Playing With Yourself… in Paris

I’m thrilled to be participating in the Web Flash Festival at the infamous Pompidou Centre in Paris this Saturday. I will be involved in a number of ways. I will be giving a talk entitled “Playing With Yourself (for fun and profit)” about the professional benefits of doing experimental work, and exploring the foundation of how my webcam experiments work. I judged the experimental category, and will present the award (my first time presenting an award… I feel so glamourous). I’ll also be setting up Installation Incomplet in the Centre with some new pieces that attendees will be able to play with.

I’m really looking forwards to meeting some of the French community at this event, even with my embarrassingly poor French (parlez vous en Anglais, s’il vous plait?). I’m also looking forward to seeing André Michelle again, his work is always very inspiring.

Sandbox Errors Not Shown When IDE Not Installed

This is more a reminder for myself than anything, and to save others the half hour of grief I went through…

While setting up the Installation Incomplet at FitC, I ran into some trouble. The installation allows users to save an image of themselves playing with the experiments back to our server, and view it online, but this feature refused to work on location. I spent a stressful half hour testing everything I could think of (internet, connection to our server, etc), shuffling modified files between my powerbook and the installation PC on a USB key, before it dawned on me: It was a security sandbox error, but it wasn’t displaying any errors because I didn’t have the Flash IDE installed, just the Stand Alone player.

I remember reading about this from way back when, but it totally slipped my mind. The IDE installs a file that the player looks for to determine if it should throw (developer) errors – without this file, it just fails silently. To make things worse, all my testing had been in my experiments directory which is I’ve set up as a trusted location. Definitely something to remember if you’re deploying any Flash 8 content to other users’ local systems or doing any installation work.

Going to the advanced settings online and setting the installation SWF as a trusted file fixed things right up (although the spotty internet access largely defeated this feature in the end anyway *sigh*).