AIR
Speaking at Flash Camp St. Louis
I’m excited to be speaking at Flash Camp St. Louis coming up very soon on September 3rd. Come get a jump on your holiday weekend and join us at the City Museum for a full day of great sessions and mingling.
Be sure to register right away. Space is limited, and it’s only $60 for a full day of sessions, lunch, and probably some free giveaways.
I really hope that my session will have some appeal for both developers and designers. I’ll be focusing on asset management in more advanced, dynamic, or heavier projects. When you have a Flash project with a lot of logic and thus code, and you’re talking to databases and social networks, you find that working with just a Flash FLA file isn’t enough. But how can you continue to utilize the strengths of Flash Pro for animation, composite components, vectors, and general layout? And what do you do about video, audio, social network content, xml, json, and other data sources?
I’ll be looking at different ways to address these questions, the developer and designer workflows involved, and the libraries and tools I’ve found most useful in the process.
To wet your appetite, here is an 18 minute screencast I put together covering one such strategy, the use of a SWC file to provide assets to an Actionscript or Flex project.
Use Flash Pro Assets in Actionscript and Flex Projects from David Ortinau on Vimeo.
In this screencast I use one of my favorite tools, FDT from PowerFlasher. I don’ think I mention it in the screencast, so let me highlight the 2 keystroke combinations you need to master in order to unleash all of the amazing tricks you’ll see me do.
Quick Fix - CMD + 1 (CTRL + 1 on the PC I think)
This fixes missing imports, generates var declarations, initiates new classes, generates handlers, and on and on
Code Complete - CTRL + SPACE
This keystroke is also present in Flash Builder, but has some extra oomph it seems in FDT. Type part of anything and hit it to see options on what you might mean. Also generate constructors or other code blocks.
Hope to see you at Flash Camp!
Flash Camp St. Louis
September 3, 2010
9am - 4pm
The City Museum
Categories: Flash • Flex • Freelancing • AIR • Productivity • Permalink
Generate PDFs with Actionscript using AlivePDF
I recently had a Flash / AIR project that required the ability to render PDFs. Evidently, this hasn't been a hot issue in the past for Flash applications, however I get the feeling that AIR may change that. While a web application can utilize any of many server side solutions to render a PDF to the browser, it's not the same for AIR.
In looking for a good solution, I quickly had to reset my expectations to find ANY solution. The only option that fit the bill was AlivePDF, an open source Actionscript 3 port of a PHP library. AlivePDF is maintained by Thibault Imbert.
AlivePDF comes with a SWC that you can include in your Flex application, or an Actionscript package you can import to your AS code. Here's a brief, condensed example of how I used AlivePDF in my Flash AIR project.
import org.alivepdf.*;
// setup pdf
var myPDF : PDF = new PDF ( Orientation.PORTRAIT, Unit.MM, Size.LETTER );
myPDF.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );
myPDF.addPage();
// add a background image
myPDF.addImage (myBackgroundMovieClip, 1 , null, null, false, ImageFormat.JPG, 100, 0, 0, 0, 0);
// add headline
myPDF.textStyle ( new RGBColor ( 41, 58, 140 ) );
myPDF.setFont( FontFamily.HELVETICA, Style.BOLD );
myPDF.setFontSize ( 18 );
myPDF.setXY( 10, 40 );
myPDF.addMultiCell ( 300, 1, "This is my PDF Headline" );
// add text message
myPDF.textStyle ( new RGBColor ( 0, 0, 0 ) );
myPDF.setFont( FontFamily.HELVETICA, Style.BOLD );
myPDF.setFontSize ( 14 );
myPDF.setXY( 10, 50 );
myPDF.addMultiCell ( 300, 4, "This is my text….lots of text…" );
// save PDF to the desktop
var f : FileStream = new FileStream();
var file : File = File.desktopDirectory.resolvePath("MyPDF.pdf");
f.open( file, FileMode.WRITE);
var bytes : ByteArray = myPDF.savePDF(Method.LOCAL);
f.writeBytes(bytes);
f.close();
Notice I'm using the method addMultiCell to add text. This may seem odd, but what this allows me to do is add a block of text that wordwraps. If I use addText then I only get a single line.
AlivePDF is definitely still young and I've run into a few oddities (read bugs). I logged a bug on the Google project site and within no time at all received a note saying the issue had been resolved and would be released in the next build. Nice!
The Google project site provides a few examples in addition to the samples provided in the download. And the documentation is fairly helpful.
Note: Thibault just released 0.1.4.1, a minor revision the codebase I've been using at 0.1.4.0. Hopefully this is a sign that the project is picking up some momentum!
If you need to generate PDFs from your Flash, Flex, AIR applications using only AS 3.0, then this is your best (only) solution.
Categories: Flash • AIR • Permalink
AIR Local Data Storage
Greg Hamer gave a fantastic presentation today as part of the Adobe Developer Week seminars on Local Data Storage Options with AIR. I think it's safe to say that Greg overprepared his material as it was run and gun from the start. If you like rapid fire learning, this is your guy.
Greg covered all the options available in AIR, demonstrated side by side read/write benchmarks for each, and discussed the pros/cons of each method so you can choose the most appropriate for your needs.
The four options available are:
1) Local Shared Objects
2) Encrypted Local Store
3) File System
4) Embedded SQL Database
Greg posted his slide deck, a link to his recorded session, and sample code on his site. It's well worth a look.
Categories: Flash • AIR • Permalink


