SWC File as Embedded Runtime Asset Library

March 20, 2012

This post is really for myself so that I have somewhere that I can look this up again. Maybe it’ll be helpful to someone else in to the future too.

When working in flash (which I find myself doing less and less now a days), one of my favorite ways to work with assets is through the use of swc files. That’s what they’re there for anyways right? Well what’s not so obvious is how to use swc files to load assets at runtime without using the import command. There are times that it’s useful to refer to an asset at runtime by name that you may or may not use, so you don’t want to explicitly go through the hassle of writing the lines to embed it. This often happens with sounds or items that are easier to loop through to use, such as when using a map of the US. It’s much easier to write a loop vs writing 51 embed statements (yes, I know that there are a million different ways of doing this without writing all of that).

When you do something like going through a loop and saying getDefinitionByName(“state_”+i) to grab a library item that resides in the swc asset file, there are no compiletime errors because Flash Builder can find that swc in the library. But once it runs, the debugger will yell at you. To fix this, you need to embed the swc file at compile time. In Flash Builder, this is done in the Actionscript Compiler settings and all you have to do is add this line (replacing it with the path to your asset swc file obviously)

-include-libraries /assets/assets.swc

Now when you run your swf, it’ll work like a charm and you’ll have those assets available without having to import them in the head of your class file. That being said, be sure to only do this when it makes sense. This embeds the swc file into your swf. So if there are assets in the library that are outdated and set to export at compile time, they’ll be included adding extra senseless bloat. As I write this, I’m using this method for a prototype where bloat doesn’t really matter, but just be mindful of that.

JS1K 2012 Entry – Heart Strings

March 9, 2012

Spider Web heart

I submitted my first ever JS1K competition entry. Really, my first javascript or any kind of programing contest entry. And I’ll admit that it was quite a challenge too. It was like a putting together a jigsaw puzzle that you have extra pieces to. For my entry,  I decided to take something that I worked on previously and rework it into something that fit the theme and into the 1024 byte limit. The theme for this year was love, so what I did was reworked the spider webs explorations that I had previously worked on into a heart shape and simplified it a bit. I also stripped out anything that wasn’t pure javascript. In the process, I was able to reduce my demo from 25K (not including the processing and toxiclibs js libraries) down to 1022 bytes.

March 2012 Project – A Redesign

March 1, 2012

For March, I’m going to work on a project that is overdue and will benefit myself along with anyone interested enough to read this. I plan on redesigning this blog that you’re reading right now. Finally.

When I first did the design of this blog, I was doing mostly flash work and just relearned how to correctly build a website from scratch. And by that, I mean building a website without using tables to place page elements. I was also working my way through figuring out how wordpress works. I was happy when I was done, but I knew that there was a lot to fix and improve. I also didn’t know if I was going to be into this whole blogging thing so I didn’t even bother to fix anything. Fast-forward a few years and I’ve rededicated myself to blogging regularly and I have experience programming in so many more languages than actionscript and have done another site on the wordpress platform that I’m ready to correct my mistakes and set up a blogging environment that I can be proud of. I don’t do nearly as much design anymore though, so I hope to get some input from some of the excellent designers that I’ve met since the initial design to help elevate this whole thing.

The goal for this month is to just work on the design part of this overhaul. The development will come later and I’m sure will span more than 1 month.

What I plan on doing includes:

  • Making a list of what works and what I like
  • Making a list of what’s not working and what I really don’t like
  • Gathering inspiration to help in figuring out what I want this to be, now and in 2 years from now
  • Figuring out a way that this blog will fit in with the rest of my online presence. For instance, I have a portfolio site that desperately needs to be updated too. So how does that tie in with this blog?
  • Figuring out how to tie things in with any relevant social media outlets (showing twitter feed, tumblr posts, etc).
  • Designing the fuckin thing

Whenever I start projects like this, I get so pumped at the beginning, only to be pissed at myself months later for attempting it. But it’s always worth it in the end. So let’s get pissed!