November 2006 Archives

How to load FlashPaper Documents in Flex 2

| 2 Comments | No TrackBacks

If you've ever tried to load a FlashPaper document in Flex 2, then you know it's not as straightforward as it was with Flex 1.5.

Sure, you can just use an <mx:SWFLoader /> tag. But, if you've tried this, you know it's pretty limited. You can't talk to the FlashPaper document, and the loaded document gets stuck at a fixed size or scales incorrectly when resized. If you try fiddling with the various scaleContent and maintainAspectRatio settings, you'll quickly get frustrated trying to achieve the perfect resize behavior.

I've run into this problem in the Flex 2 application I'm currently building. We're using ColdFusion to generate dynamic reports via the <cfreport> tag, capturing the report output as FlashPaper, and then loading the report output .swf directly into the Flex 2 application. I'm happy to say that I've solved the resize and communication issues, and I've been given permission to post these on my weblog from the client that I've written the code for.

You can download my Flex 2 FlashPaperLoader here. (.zip archive) - MIT License

There's a lot of interesting things going on the .zip file. In the archive you'll find the following files:

Compile ActionScript in ActionScript

| 1 Comment | No TrackBacks

If you haven't seen the Tamarin news by now, what rock do you live under? Did you catch the part about the new ActionScript compiler?

I don't want to rehash what's already been said. JD does a great job at the above link to send you to various places for background information, impact, etc. Instead, I want to point out something that could easily be missed in the announcement: Adobe has released a "self hosting" open source ECMAScript compiler.

As Tinic mentions, the AVM2 code does not include a compiler. Adobe has a Java compiler instead (which you can download free via the Flex 2 SDK) that was built to help support Flex Builder 2. The separate compiler keeps the AVM2 code size (and therefore, the Flash Player size) smaller, but it also means that "eval" doesn't work. The eval function takes an arbitrary string representing code, and executes it, such as eval( "x = 10; alert( x );" );

To combat this, enter the ECMAScript compiler, written in ECMAScript (ActionScript 3). Take a look at the code in this directory, and in particular the parser itself. It's an interesting piece of work, but is only partially complete.

It's exciting to see this in development. As this code matures, we should have available to us a runtime compiler that can interpret ActionScript 3 code on the fly. I'm not sure that I'd use it much in my daily Flex work (I haven't had the need thus far anyway), but I appreciate the effort behind this and am looking forward to seeing it in action.

Tags: , ,



About this Archive

This page is an archive of entries from November 2006 listed from newest to oldest.

October 2006 is the previous archive.

December 2006 is the next archive.

Find recent content on the main index or look in the archives to find all content.

Archives

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.02