Le Tour de Adobe

Well, it’s that time of the year again, the Tour de France has once again begun in ernest. Because of the time difference here in Australia, i’d usually be sitting in front of the telly growing dark eyes for the hours of 11 to 3 watching the coverage live.
Continue reading

Unique records in AS3

I’m sure others already know this little trick – but in case you didn’t…

The filtermethod for Arrays in Actionscript 3.0 comes in handy if you want to (ahem) *filter* certain elements out of your array :


var tmpArray:Array = ["oranges", "apples","oranges", "pineapple", "carrots", "oranges"];
var fruits:Array = tmpArray.filter(function(e, i, a){
   var isUnique:Boolean = (a.indexOf(e) == i);
   return (isUnique);
}, this);
trace(fruits.toString());

Continue reading

A few days on PaperVision3D

So last week I had the opportunity to get my hands dirty with PaperVision3D. As mentioned previously, the company I work for has been responsible for implementing the 2008 Earth Hour website.

Well, as part of that, I had a crack at visualising the global support being given to the Earth Hour movement. Using AS3, I first load in a zipped text file containing lat/longs of each user sign up, and of those users broken down by country, which I uncompress and iterate over to create textures. I then use PaperVision3D to generate a set of spheres which I wrap the textures around, and add some simple mouse interactions.

I settled with an early release of the engine – but am keen to have a go at the 2.0 branch and see if it speeds things up.

Global Earth Hour supporters

Flash 9 player is required to view this content. It can be downloaded from Adobe.com

Tags vs Text

Over at my work blog, we have just uploaded a post about how we created a Flash Text Cloud for one of our recent clients.

Bottom line, if you are in need of a faux tag cloud made in Flash, there is both a download and example for you to enjoy. And if you’re interested in tossing up how to go about creating your own tag (or text) cloud, we’ve also outlined the reasons we used Flash and not CSS.

Hello Facebook!

So, at work we are currently doing some testing out of the Facebook API, and short of coming up with the next best idea on the web, I decided to re purpose a version of Solitaire I made a few years back in Flash.

So here is is for everyone to enjoy :

Solitaire

Actionscript 3 XML Weirdness

Weird. Have just been working on a project in AS3, and have been scratching my head over a blank trace from what (as far as I could see) should be a simple XML lookup.

[kml_flashembed movie="/blog/swf/xml_trace.swf" height="350" width="300" version="9" /]
Direct link to SWF

An example of the XML im using :

<pictures>
  <img src="example.jpg" />
</pictures>

The ActionScript :

function BuildImageList(vXML:XML):void{
  trace(vXML.pictures.img);
}

As far as I was aware, this should output <img src=”example.jpg” />, but it doesn’t – it just outputs blank. However, if I change the XML file and add a second <img /> node :

<pictures>
  <img src="example.jpg" />
  <img src="example.jpg" />
</pictures>

… it works :| . As expected, it traces 2 <img /> nodes. Is this a bug, or am I missing something?

A week on ActionScript 3.0

So I’ve spent about a week now hacking away at the latest incarnation of Flash ActionScript. It’s been an interesting journey, and one that is getting more and more rewarding, the longer I spend time with it. AS3 has been around for a while now, but the nature of the work that I do on a daily basis has meant that I’ve not had a. the need, and b. the opportunity to actually spend any time learning it up until now.

Late last year I spent a day looking at some tutorials, and following on with them – but the only real way I know to really learn something is to actually do it. As a self-taught slash web-taught coder, it raises interesting challenges – as you rely on other’s sharing and structure to begin the process.

As part of the learning process, I set up labs.shiftperception.com/ – which I intend to fill with useful examples (for my own future reference as much as others). As is often the case though, at the moment it belies the amount of learning i’ve undergone in just a short week. However, the process of making the labs itself gave me a great start to feeling confident approaching development using this new codebase. Some reflections:

There are some really smart people out there, ready to help.

It can be daunting at first, to realise that there are soo many really good Flash developers out there that are doing amazingly cool stuff… but as you dig deepeer, you realise that these same developers are the first to offer help, examples and understanding that quite frankly put the Adobe help files to shame. I’m quite sure some of these same people either worked closely with Adobe to develop AS3, or helped test it, and if they didn’t, they should. A few links to help the weary searcher (ive posted many of these before, but well worth doing again! bear in mind it’s non-exhaustive) :

Flash is moving away from designers, and towards developers.

I know, it’s a bold statement, but it feels true. What I mean is that, yes – for all intense and purpose, Flash CS3 still functions the same as Flash 8 and MX2004. As a designer I can still go in and add MovieClips, manipulate the timeline, and do all my usual tricks using reasonably simple AS2 code. But as soon as I want to do anything specific to AS3, simple things become a lot more difficult to understand – memory management, adding and removing event listeners, and that’s not even approaching Classes and that can of worms. These are the realms of the developer. Someone versed in the language of zero’s and one’s. Not your average Designer. Not even (for the most part) your very good designer.

This is a very interesting point, because it seems that Flash, as it becomes ubiquitous on multiple devices, and as the language matures, it is invariably becoming a true development environment, aimed less at the original target market, and more and more at the developer. And it’s a very difficult juggling act to make. I wonder how long until a completely developer-oriented version is made?

I’ve been lucky enough to have access to a mate of mine, OJ, who – while not a Flash developer, is an extremely good programmer in pretty much everything else… and the great thing (at least for me) is that, while knowing next to nothing about AS3, he’s now able to help me with my coding woes. Sure there are some Flash-specifics that he needs me to enlighten him about, and he could certainly help me with theory in older versions of AS, but because AS3 now more than ever closely resembles other standard programming languages, people with skills like his can now give advice and help to us lowly slashes.

Migrating from AS2 to AS3 is not as simple as you think.

Unless you came clean into ActionScript at version 2.0, and embraced the developer’s approach to writing code, and even if you did – some fundamental things have changed between AS2 and AS3. Like dynamically attaching a MovieClip. Like references to _root, _parent and _global. Like keyboard events. If you have a project in AS2 that uses any of these, and want to port it to AS3, depending on your competencies as a programmer, this might not be a worthwhile task.

And for the designer, the inability to have code backwards compatible might not make sense. IE, in AS2 there was code from AS1 that you could still use, ie the fundamental way you went about doing things remained the same. Not so when making a project for AS3.

Give it a week, AS3 will grow on you!

If you are a reasonably competent coder/hack, you will really enjoy the move to AS3. It will be painful at first, but there is so much opportunity in the latest incarnation that it will be worth it in the long run.

In the near future, hopefully you will be able to see the fruits of my toils, but in the mean time, ill try and gather snippets together into useful downloads and post them in the lab. It may take a few weeks, but I think they will still be of use :)

ByteArray, AS3 experiments

These guys are cool : ByteArray.org. Check out their implementation of JPEGEncoder, and their new experiment in GIF exporting :) (oh, and drool at the mouse gesture example!!). Makes my simple “hello world” look… well, ah, simple!

Hello World!

So, slowly getting there with the labs.shiftperception.com/… at the moment it’s trying to find the time to get a format im happy with. I’m nearly there, and if all things are working correctly, you should be able to see the first item i the lab by hitting this link : Hello World. Likewsie, on the labs page, you should be able to get back to this blog entry to discuss…

Fingers crossed!

SmartSketch

This has happened before, as highlighted by Senocular, but I just opened up Flash and as it launched, the application name again was showing as SmartSketch – the original name of Flash. Perhaps a Friday 13th easter egg?