Flex Ant Tasks and FlexFileSet error

  • December 11th, 2008

*This is more of a post-reminder or a google-search aha than a soliloquy on the joys of FlexTasks and how to use them. If you want to know more about flextasks, visit here, or Ryan Taylor's blog for some good tips, or pick up this wonderful book... the holidays are coming.

I have had the fortunate opportunity to work with Andy Zupko on a project here at Infrared5. We have our good days and our bad days - as most projects go - and hopefully we'll be able to showcase our efforts at some time. Recently i started whipping the project into shape to handle modules, rsls and loaded styles to minimize the download time and highten user experience. Why does it always come down to the last few days to get this up and running? I don't know. Maybe we're so gung-ho to get things finished for an iteration and to show a client that deployment structure falls a little to the wayside. In any event Andy, and in some part me i suppose, structured the project to have minimal impact when it came time to have a deployment routine and manage runtime styles and rsls. Enough horn-tooting! What am i talking about?

Well, when it came time to set up the ant tasks that will take over the deployment and distribution of the application i was hitting a wall in compiling against an rsl. More to the point, i was getting this error:

CODE:
  1.  
  2. BUILD FAILED : No directory specified for FlexFileSet.
  3.  

... when combined with this directive

CODE:
  1.  
  2. <compiler .external-library-path>
  3.         <include name="${app.dir}/${rsl.name}.swc" />
  4. </compiler>
  5.  

I'm not gonna go into the nuts and bolts of the build file or even attempt to explain what that error means. I am familiar with compiling applications and modules from the Terminal and pretty much love doing most things from the terminal rather than relying on tools in eclipse, but i thought to bring experience down to a playing ground for a project that will be handed off to a client at some point, go with flex ant tasks. It's well documented. Google finds most answers. Etc. But there are subtle changes to syntax that i am unfamiliar with when it comes to create a build file targeting the command line tools of the SDK.

In any event, it baffled me why this command would not work. It syntactically looked correct to me. The compiler directive is spelled correctly, the option variable is the correct path... wtf. Well just like the -library-path option i suppose you had to remove the directory that the SWC lives in from the variable and add it as a dir property.

CODE:
  1.  
  2. <compiler .external-library-path dir="${app.dir}">
  3.         <include name="${rsl.name}.swc" />
  4. </compiler>
  5.  

Works! All is fine... but it took a hell of a long time to figure that out. Thought i would post this for any Terminal monkeys out there that run across this issue when building an ant file for compiling rsls into your application.

Was I bone-head for 2 hours? Probably.... feel free to leave a comment.

Back from MAX

  • November 23rd, 2008

Just got back from Adobe MAX and a sweet short vacation for the missus and i. Been to SF only once, when i was 9, and all i cared about were Garbage Pail Kids and pleading with my mom to buy me some Nikes. Needless to say, i remember - i think - a lot more about this last trip.

I was overjoyed to be able to sit on the Flex Architecture Face-Off panel with Chafic Kazoun, Josh Noble and Yakov Fain. They are amazing architects with strong beliefs and open ears. We had a pretty good turnout and the session ended up being sold out. Only noticed one person walk out, but as it turns out they were over-caffeinated...

It was my first MAX and i didn't know what to expect with the record-breaking attendance and my bundle of nerves. All said, i really enjoyed it and renewed my interest in the software platform that constantly evolves and inspires me to keep digging even after the workday is over. Of course it was centered around Adobe products, but i truly got the sense of it being a presentation rather than being force-fed. A lot of great things are on the horizon and even though i am a mark-up snob in a sense, i love the direction that the Flex platform is taking. Would have liked more 'inspire' sessions, but Ryan Taylor, Andre Michelle and Mario Klingemann kept me wide-eyed and ready to go back to my room to code... although there always seemed to be free beer that blocked the exit :)

Adobe also sponsored a party on Tuesday night at the de Young and Science Academy. I thought that these were venerable institutions in Golden Gate park, but it was dark and as I later found out after going with the missus again later in the week that the are relatively new. If you are in the SF area anytime soon, i highly recommend checking them out. That was a great night with two great museums and some really great friends... plus me and Josh schooled some poor saps in Foosball... after i got schooled in NBA Jams by Ash - rematch, all i'll say.

Some people found me after our panel and had some questions about things i brought up that i wish i could have gone into further:

1. As far as specs, docs and architecture go, I think your best bet is Enterprise Architect. That is, unless you are on a Mac in which case it is not available and i prefer Omnigraffle.

2. I briefly mentioned Prana and IoC as a segue from scaffolding and I wish i had more time to devote to it during the panel. Though Mate does support some dependency injection for their event mapping, it is compiled in and i prefer an external application context that can be configured for runtime. We use it heavily at Infrared5 and I would whole-heartedly suggest you look into it for your next project - Prana developed by Christophe Herreman.

3. On the panel, we were all familiar with Cairngorm and mostly use it when business requirements and dev team size makes it a perfect fit. But i did bring up the black hole of state control that comes with it... in my opinion. I am quite taken with how PureMVC handles state through mediators, but i have other weight-baring problems with PureMVC that i can't get around that make me choose Cairngorm when it comes to incorporating a micro-architecture into our projects. I basically said that i hate throwing string-denoted state on the ModelLocator that is bound to a view. I can't stand it, but i do it because i know that developers are familiar with it. In my personal opinion i think this is the best case for the Strategy pattern. I like the Mediator pattern as well, but i think there is too much baggage and extra code that needs to be thrown in an if..else of switch..case. I know that Strategy is behaviour pattern but i see it fitting in nicely with presentation as well. I can go into that farther in another post if you all want, but i just wanted to convey that even though you might represent a simple string on a global model, i think you are losing the loose-coupling infrastructure... but don't even get me started on Singleton models... this 3 point has already run too long.

In any event, if you sat in on the panel, I would love to hear your thoughts - good, bad and ugly. Leave a comment... and bundle up, it's cold here in boston.

Errata or just a helpful hint?

  • September 3rd, 2008

For those of you who have a copy of the Adobe Air Create-Modify-Reuse book that myself and Marc Leuchner and Matt Wright (of NoBien fame) authored, we hope you are enjoying it and i also may have a bit of errata for Chapter 1 if you are running Leopard. For those of you who don't have a copy of the book (go buy it) and/or are running Leopard and want to use the Flex SDK command line tools, this may be of interest...

In Chapter 1 of the Adobe AIR Create-Modify-Reuse book, The Development Environment, it states that in order to set a PATH variable for your command line tools that you should:

1. Open the Terminal and type > open -e .profile
2. Add the path to the /bin folder of your SDK installation (I paraphrased... but you get the idea)

In Tiger this is all well and good, and if you are running in Tiger you can drop off or read on if you intend to upgrade to Leopard. Setting system paths in Leopard has changed and you no longer have a .profiles file in your User directory to which you can add/append paths. The following steps are what i took to add a path to the Flex SDK command line tools under Leopard:

1. Open the Terminal and navigate to /etc/paths.d
2. Create a file named 'flex' - (sans quotes)
3. Enter the following command: > pico flex
4. Enter: /Applications/flex_sdk_3/bin
5. Exit and Save

You will need to restart your computer.

*Note: /Applications/flex_sdk_3/bin points to the /bin directory of my Flex 3 SDK installation, change as you see fit to your installation.

I can't go into the long and short of why this needs to take place in Leopard, but that will get you up and running with the command line tools if running under Leopard; i can however tell you i used the following to set me on the right path (no pun intended):

here and here

I apologise if anyone had purchased the book and tried to go through Chapter 1 with a Leopard installation. I did not know that setting PATH variables had changed and I was running Tiger when written and up until about a couple weeks ago when my HD went on the lam and i was greeted by a series of 'Do Not Enter' and 'Missing File' icons on start-up... all is well though, and they replaced my HD and installed Leopard for free!

For those of you have a copy of the book, i hope you are enjoying it. For those who are trying to get the tools up and running and just switched to Leopard i hope this is useful.

Flash on Tap : Boston

  • August 7th, 2008

Beer and Flash.

Now, i plead guilty to introducing the two from time to time ... and sometimes more of one than the other. : )

... and here comes an opportunity to mingle micro-brew tasting with some of the most intelligent minds in the business... and in Boston no less!

Flash on Tap is in Boston from October 7th until the 9th. Get you tickets while the super early and early bird special last!

Flex 3 Cookbook clarifications

  • July 15th, 2008

Josh Noble - the main man behind the Flex 3 Cookbook of which i had the esteem pleasure of being part of (thanks again, j-man) - has recently blogged about some more information involving the files for download and the intention of the book.

Wanted to blog about it as well, as i feel there is some great information from his post about the decision for cutting chapters and where to download code and the best way to submit errata. He also mentions the heartbreaking decision to cut chapters and recipes from the book to preserve page count... but don't put the book back on the shelf, they are available to download!

We hope people are enjoying the book at what any level developer you are. Cheers to Josh and happy coding!

read Josh's post

Yet another post about Astro

  • May 15th, 2008

If you read MXNA, you probably have stopped checking quite some time ago because every post is about Astro...
but if you are interested in another way to set up your projects in FlexBuilder to target FP10 without having to muck about with files in the frameworks folder of your original Flex3 SDK installation this post may shed some light.

I am a workspace fanatic when it comes to development. I like things tidy, and when i start a new client project or go into some new exploration that involves multiple projects, i create a new workspace. The great thing about workspaces for me, aside from keeping things neat in my head, is that each new project you create in that workspace inherits from any default settings. So when the big news hit and i wanted to check out the latest SDK, i created a new workspace and followed most of the excellent directions already available on the adobe open source site. I only strayed a little in how i went about setting my workspace up so that every new project i created in it was *almost* set for development targeted at FP10 without having to run through the process each time.

The following is the process i took to only mess with the files from the nightly build and set defaults for a single workspace in order to play around with the current features available in Astro:

1
. Download Flash Player 10 codenamed Astro.
2. Download the nightly build and unzip to some directory. (for me that is /Applications/flex_sdk_3.0.1.1728
3. Open FlexBuilder or Eclipse (if you have the plugin) and create a new workspace. (ie. ~/Documents/workspace/astro).
4. Create a new project.
5. Navigate to Project>Properties
6. Select the Flex Compiler option
7. Under Flex SDK version, click Configure Flex SDKs...
8. In the Preferences (Filtered) window, select Add
9. Navigate to the installation of your nightly build. (ie. /Applications/flex_sdk_3.0.1.1728)
10. Add a new name for the SDK... you should see something like so:

Flex Builder Astro set up'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

11. Click OK, Then tick the checkbox next to the newly added sdk in the Installed Flex SDKs window.
12. Click Apply, then OK.
13. Then back in the Project Properties folder, under Use a specific SDK, if the newly added SDK isn't selected, select it.
14. Under the Required Flash Player Version, change the value to 10.0.0
15. In the Project Properties window on the left side, select Flex Build Path> Library Path.
16. Expand the SDK you just set as default, and select the playerglobal.swc and Remove it.
17. Click Add SWC, and navigate to the player 10 swc from your nightly build SDK installation (ie. /Applications/flex_sdk_3.0.1.1728/frameworks/libs/player/10/playerglobal.swc)
18. Click Apply, then OK.
19. Open up the flex-config.xml file from the Astro SDK installation and update the settings as described in the first part of the Command-line Compiler instructions from here.

Thats it! Only 19 steps... that seems like a lot. In any case, in ensures that any project you now build under that workspace will default to using the targeted SDK. You will still have to manually change the Required Flash Version (from step 14) before you compile a new project, but other than that when you want to tinker with the nightly build - and not mess with your stable Flex 3 SDK release that other projects in other workspaces are targeting - just hop over to that workspace.

Good reading
:
Ryan Stewart - Flash Player 10 codename "Astro" goes beta
Tinic Uro - Adobe Is Making Noise series
Keith Peters - Astro Dynamic Sound!
Josh Tynjala - Gratuitous Text Effects

Prana and compiled classes

  • May 10th, 2008

I have recently gotten into incorporating Prana - the Inversion of Control framework of AS3 created by Christophe Herreman- into my projects. I gotta say, it's beautiful piece of work and makes me rethink my approach to the architecture of applications again.

I don't want to go into IoC and dependency injection and how your applications can truly benefit by using the Prana framework, as this post may get pretty long and these references are much better reading than my rambling:

Christophe's blog: http://www.herrodius.com/blog/
Martin Fowler's Inversion of Control Containers and the Dependency injection pattern
the hollywood principle

What i did want to bring up is that i had a small problem with the workflow and how i develop. Which is my problem, of course :) but nonetheless...

One important thing to remember is that the context file is an external file that is loaded by the application at runtime. This means you will need to have all the possible classes your application may use already compiled into the SWF in order for the objects to be instantiated and your application to work. If you are typing to interfaces, this could prove to be a bit of a problem. You could create a reference for each class that may be needed in another class that is known to be compiled into the SWF - as Christophe explains in this post - but that always seemed dirty to me.

As is mentioned in the comments to that post, you can also go about adding each class using the -includes compiler option. Adding all possible classes using the -includes option makes for an excellent case on when to use additional compiler configurations, and presents the option to really just change the application context file and the additional configuration file as the project sees fit, without having to open up the source and tack on or remove dummy references to classes.

As an example, take for instance this application context file:

XML:
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3. <objects>
  4.         <property file="app.properties" />
  5.         <!-- Handles direct invocation on client -->
  6.         <object id="callbackHandler" class="com.example.responder.CallbackResponderImpl" />
  7.         <!-- Handles connection to Red5 application -->
  8.         <object id="connectionDelegate" class="com.example.business.ConnectionDelegateImpl">
  9.                 <property name="rtmpURI" value="${app.rtmpURI}" />
  10.                 <property name="client">
  11.                         <ref>callbackHandler</ref>
  12.                 </property>
  13.         </object>
  14. </objects>
  15.  

.. for each possible implementation of ConnectionDelegate and CallbackResponder that i may decide to swap in and out as the project seems fit, i would either need to hold a reference to each implementation in some class sure or be compiled into the SWF, or i could store them in an additional config file that can be added using the -load-config option with an additional value:

The prana.config file:

XML:
  1.  
  2. <flex -config>
  3.         <includes append="true">
  4.                 <symbol>com.example.reponder.CallbackResponderImpl</symbol>
  5.                 <symbol>com.example.business.ConnectionDelegateImpl</symbol>
  6.         </includes>
  7. </flex>
  8.  

... drop that in my source folder and add the compiler option:

CODE:
  1.  
  2. -load-config+=prana.config
  3.  

From there, i could change the context as i see fit, update the prana.config file to reflect my preferences and just recompile the application without having to go into the source and muck about. It's a little more clean for me and allows me to happily go about using the Prana framework.

The best part is that Prana is truthfully AS3 compliant! Meaning you can use it in your Flex AND AS3 projects, which cannot be said for some frameworks that claim to be AS3 and actually use class from the mx package... (looking at you as3lib). A huge pet-peeve of mine.
*Last i checked, the source under version control doesn't seem to reflect the current changes Christophe has made, but they are included in the downloads.

Styling the whiteBox of a Flex Container

  • April 16th, 2008

You can't... That is to say, there is no style property to change the color of that little white box that appears in the lower right of a Container component when the vertical and horizontal scrollbars are present.

Today, i added a Canvas that had fixed dimensions to the displaylist of a Flex application. Because the content within the Canvas instance would vary in size, vertical and horizontal scrollbars are needed for content that is larger than the width and height of the fixed dimensions of its parent container. When both scrollbars are present on the display, they meet in the lower right and create an empty space. That empty space is actually a FlexShape in the Container class called whiteBox. The whiteBox shape is protected, but is added and removed programmatically within private methods based on the presence of both directional scrollbars.

Fine by me... the problem i have is that the color of whiteBox is hard-coded ( to #FFFFFF ). Super! I guess if you name something with a prefix that is a color, you have to hard-code the actual color it will be using to draw...

There is an easy work-around by just creating a subclass of Canvas and overriding the updateDisplayList() method to remove whiteBox, but it seems kind of hackish, especially if it is going to be added each time the vert and horiz scrollbars are added to the display and then i have to remove it again.

Here's an example of how i resolved my issue:

Actionscript:
  1.  
  2. package
  3. {
  4.     import mx.containers.Canvas;
  5.  
  6.     public class NoWhiteBoxContainer extends Canvas
  7.     {
  8.         public function NoWhiteBoxContainer() { super(); }
  9.        
  10.         override protected function updateDisplayList( unscaledWidth:Number, unscaledHeight:Number ):void
  11.         {
  12.             super.updateDisplayList( unscaledWidth, unscaledHeight );
  13.                        
  14.             if( whiteBox ) rawChildren.removeChild( whiteBox );
  15.         }
  16.     }
  17. }

Nothing extremely complicated, but it would have been nice to just set a style property or for the fill color to inherit from the backgroundColor property. ah well... Hopefully someone may find this post if they are wondering what to do with that white box.

Looking back and looking forward

  • February 24th, 2008

For those of you that still follow this blog, you may have noticed that i have not been too knee-deep in blogging. A measly 5 posts ago, i rambled on about what 2007 might bring. Needless to say it had kept me pretty busy - and for all good reason. I have had the opportunity to work alongside some unbelievably talented people and be a part of two amazing books focused on Adobe AIR and Flex 3 that will be hitting shelves soon. I also accepted a position at Infrared5 and am looking forward to working with some of the most insane and brilliant minds in the industry.

AIR Create-Modify-Reuse
Marc Leuchner and Matt Wright (of NoBien fame) and I have been burning the midnight oil to deliver an exciting book on Adobe AIR - AIR Create-Reuse-Modify from Wiley Wrox press. Each chapter walks through building applications as you learn about the AIR API. We had a lot of fun architecting and writing about each application that highlights specific facets of the platform and hope it is as much fun to read. Adobe AIR and the API is part of the Flex 3 SDK, which might be coming out soon...

Flex 3 cookbook
Well, i didn't stop at discussing one part of the Flex 3 SDK and also was asked by Josh Noble to be a co-author for the Flex 3 Cookbook from the O'Reilly press. We've gathered the submissions from the Adobe online cookbook and Josh has been steering the cookbook ship to greatness. If you are unfamiliar with the O'Reilly cookbook format, the book is designed to present hundreds of 'recipes' aimed at solving programming problems. I have had the extreme pleasure to write about parts of the Flex API that i love and believe to be essential to RIAs developed using the Flash Platform.

If writing didn't keep me busy enough, I worked with some amazing people while building applications that stretched the possibilities of what online and desktop applications built in Flex can do. Along the way i learned more about the business, some agile practices (which i hope to write about some) and how to have fun and love what i do. It is an amazing thing.

Infrared5
I also have had the opportunity to join the Infrared5 team and could not be happier. Infrared5 is a consulting company started by Chris Allen, Rebecca Allen and Dominick Accattato focused on architecting applications using the Flash Platform and Red5 Server technologies. Keith summed it up pretty well in this post. I am honored to be in company with some of the brightest minds in the field that keep me laughing throughout the day. Once I stop breaking things around the office, i can settle in and learn something :)

All in all, 2007 was a great year and i am making out 2008 to be even better. Here's to posting more!

Extra tracks and how things change

  • October 16th, 2007

To start off, recently i have been working remotely for my job... whole 'nother discussion... and what was once the 'office' (read: extra room where we didn't know where to put stuff and has my computers) i retired to during the nights and weekends has become my proper 'office' (read: i am in here all the time now). Essentially what this has boiled down to is having no boundaries of what music i can put on at any time - aside from the albums i had to leave behind at the store until i get another check and can free them.

This also has lead to me digging around and discovering some old gems that i just never bothered to bring to work or put on the iPod. And i started to notice with the CDs that some of them would end. I'm enjoying my coffee. Hmm. It's nice outside. Should i ta... 'BA-DIT-IT-Y DUM WHIRRRRrrr'. What the hell is that!?! Oh... yeah... extra track stuck on the end of the cd... you can get out from under the desk now.

Does that happen any more? I haven't bought a CD in a long time that has that 4+ minute dead space at what should be the end of the CD that then drops that hidden song on.

Todd at 14: 'It's not even freaking labeled on the jacket!?! What's the name of this song? It's awesome. Did Tim know that was there? Oh, man. That's going onto the next mix tape.'

Todd just may have dated himself...

Anyway, I got to thinking... a) what happened to that suprise? is it that they still make 'material' CDs only for poor schmos like me who like to hold something and that the production is no longer based on someone buying more than one song? b) i wonder what the equivalant in the internet world this 'extra track' phenomenon is?

The answer to a) is probably yes and the fact that it was a fad. There was a time i couldn't buy a CD without expecting an extra track hidden at the end, and i would spend my time hitting the seek button until i heard something. Was i disappointed if their was no extra track? Only if the rest of the album sucked and i felt i was suckered in by one song to buy it - looking at you Live. (remember this was a time before you could preview anything on the internet and it was a godsend if a record store had opened CDs you could pre-listen to...)

The answer to b)... hmm. Don't know. I am always tempted to say 'skip intro'. But i don't know... that wasn't really a treat most times :)
And, aside from obvious design and nomenclature, i am wondering if there was something that was prevalent on applications or websites that you couldn't get away from whether you were interested or not... kind of like how you can't buy a decent glam album nowadays without it being remastered with more extra tracks than the original album had. Good and bad and leaves you wondering how long it will last and if you really care if it's gone... but you'll write a blog about it 10+ years fter the fact.

I don't know where i am going with this. Just rambling and looking at the crates of LP's and stacks of CDs for something new to listen to...