Multimedia Development
Flash, Flex, AIR, ActionScript 3.0
Processing, OpenFrameworks
 


Flash Snapshot Application – an AIR/Flickr/Moo mashup

May 27th, 2008

There’s lots of fun to be had with Moo mini-cards, and I’ve been getting good feedback on the batch of fractal cards I made recently, which were created by taking snapshots of one of my flash experiments. The magic behind this was so simple I may as well share it with you. All you need to create your own set is the Flex/AIR app I created, which you can download here, and a Flickr account. This is how it works:

You give the app the path to your swf, and hit enter. It then runs a function to start a timed loop, as follows:

private var _saveDir:File;
private var _timer:Timer; 
private var _counter:int;
private function startSnapshot(url:String, time:Number = 5):void {
    // loadedSwf is  the name of the mx:Image that 
    // will contain the swf
    loadedSwf.source = url;
    // create a directory to store our snapshots
    var dirName:String = "snapshots";
    _saveDir = File.desktopDirectory.resolvePath(dirName);
    var x:Number = 1;
    while (_saveDir.exists) {
        _saveDir = 
          File.desktopDirectory.resolvePath(dirName + String(x++));
    }
    _saveDir.createDirectory();
    // start loop
    _counter = 1;
    _timer = new Timer(time * 1000);
    _timer.addEventListener(TimerEvent.TIMER, snapLoop);
    _timer.start();
}

Then, while the swf plays, the timer loop fires this function every few seconds to take a snapshot:

private function snapLoop(e:TimerEvent):void {
    // create a new BitmapData object based on the 
    // size of the loaded swf 
    var BMPData:BitmapData = new BitmapData(loadedSwf.width, 
                loadedSwf.height, true, 0xFFFFFF);		
    // take a snapshot of the swf, and store it in 
    // the BitmapData object
    BMPData.draw(loadedSwf);
    // encode it as a jpg
    var jpgEncoder:JPEGEncoder = new JPEGEncoder(80);
    var jpgBytes:ByteArray = jpgEncoder.encode(BMPData);
    // save it
    var ourFile:File = _saveDir.resolvePath("snap" + 
               _counter++ + ".jpg");
    var fileStream:FileStream = new FileStream();
    fileStream.open(ourFile, FileMode.WRITE);
    fileStream.writeBytes(jpgBytes, 0, jpgBytes.length);
    fileStream.close();
}

Note that the BitmapData snap may give unexpected results with transparent swfs, so it is best used with swfs that have a solid background.

Once you have a folder full of snapshots, upload these to Flickr. For this example I pointed the app at a local version of my favourite fractal experiment swf, to produce this set of images.

To turn these into mini-cards, the final step is to use Moo’s Flickr import option. Point it at the Flickr set you have created, pay your money, and in 10 days or so a pack of groovy cards pop through the postbox. Simple.



My Ten Most Important Lessons Learned At FOTB07

November 10th, 2007

1. Generative Art is very in this season.

2. Just about everyone seems to think we should be rediscovering the play in our work.
Even Keith Peters was suggesting we quit our jobs and start making casual games for a living. (Next year the theme will be “Flash – not just a toy”)

3. There is a revolution in Flash audio just around the corner.

4. 99% of what we do as developers is shit, but we need to do shit to make that 1% of masterpiece. (Andy Polaine paraphrasing Hemmingway)

5. Flex is not exciting any more, it just IS.
(Same goes for everything else we were excited about following FOTB06 – Papervision, AIR, etc)

6. Flash is so last week. We should all be learning Processing instead.

7. The Dead Sea is dead because nothing flows out of it. This is why we should be giving away at least 10% of our stuff. (Chris Orwig) Preferably 10% of the shit, not the masterpiece I presume. (Personally, I advocate giving it all away).

8. MicroSoft Expression? Get outta town (or to the end of the pier at least).

9. A Flash experiment is never finished, only abandoned. (Jared Tarbell paraphrasing Valery)

10. All the smart money is in print-making.

natzke print



FOTB: Joshua Davies

November 6th, 2007

joshua davis print

My clear highlight of Flash On The Beach 2007 Day One was seeing the work of Joshua Davies. His abstracts are incredible, but they get even more interesting when you delve into the process behind their creation.

Read the rest of this entry »



 
actionscripter.co.uk.com actionscripter.co.uk.com actionscripter.co.uk.com