Categories
AS3 Flash

My first AIR app: SWF2GIF-banner – part 1

Sometimes, and I’m not very fond of them, I need to make banners…..
The animation part is not so bad, but making the different sizes…. that can be a drag.
And after you made the SWF banners, you also need to make the animation in GIF.

This is how I use to do it:

  1. make the SWF banner
  2. embed it in a html page with a background color that is not in the banner itself (a border around the SWF banner helps)
  3. make snapshots of the animation
  4. open photoshop >> (I used a action for this part….)
  5. place all the images in one document
  6. cut the browser from the screenshot
  7. select the background-color reverse the selection and cut
  8. make a animation from all the layers (end photoshop action)
  9. save

I have never made an AIR application but I think that it should be possible to make a SWF2GIF converter in AIR.

Stuff what I need to find out:

  • browse for a file
  • load that file into air
  • take snapshots of the animation
  • controle the frame rate of the animation
  • make a animated gif
  • save everything
  • etc.

Lets start with some basic:
I’m still working on CS3, and it seems that AIR default is installed with CS4
Installing the Adobe AIR update for Flash CS3

English: http://help.adobe.com/en_US/AIR/1.5/devappsflash/WS5b3ccc516d4fbf351e63e3d118666ade46-7fc3.html
Dutch: http://help.adobe.com/nl_NL/AIR/1.5/devappsflash/WS5b3ccc516d4fbf351e63e3d118666ade46-7fc3.html

You can also use FlashDevelop 3.0.1, AIR is also installed with that program and in combination with Flex sdk you don’t even need Flash.

Because I’m not finished with it (I will only work on it when I have to build banners) I will post now and then some parts of the code.

For some reason I couldn’t find the code to load SWF into AIR using “browse”.

[as light=”false” wraplines=”true”]
private function openSwfFile(e:MouseEvent = null):void
{
var imagesFilter:FileFilter = new FileFilter("Flash SWF", "*.swf");
myFile = new File();
myFile.addEventListener(Event.SELECT, selectHandler);
myFile.browseForOpen("Open", [imagesFilter]);
}

private function selectHandler(event:Event):void
{
myFile.removeEventListener(Event.SELECT, selectHandler);
loadSWF(myFile.url);
}

private function loadSWF(inName:String):void
{
trace( "Main.loadSWF > inName : " + inName );
mLoader = new Loader();
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
mLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onErrorComplete);
mLoader.load(new URLRequest(inName));
}
private function onLoaderComplete(e:Event):void { startOnEnterFrameHandler(); }
private function onErrorComplete(e:IOErrorEvent):void { trace( "Main.onErrorComplete > e : " + e ); }

private function startOnEnterFrameHandler():void
{
_movie.addChild(mLoader);
// _movie.addEventListener(Event.ENTER_FRAME , onEnterFrameHandler);
}
[/as]
just use a button to activate.

I know the code is not complete… and that some classes have strange names… it’s work in progress.