What Music Puts You In The Zone?

Recently, my wife's desktop was acting up and for about 2 days I was unable to play music while I was working.  I forgot how difficult it is for me to code in silence (or near silence).  This got me thinking, when I need to focus and just crank out code, there is a certain album I listen to, James Taylor LIve (CD1 and CD2). For some reason, that album always puts me in the zone and I can code like a madman.

So, when you need to be heads down, and crank out code like its no body's business, what do you listen to?

Hey big boy, want to see my Iron Man?

CF.Objective() starts in a few weeks on May 1. Coincidentally Iron Man is being released the following day. If you would be interested in seeing the movie with some of your favorite (or maybe not so favorite) ColdFusion geeks, leave a comment here, and be sure to subscribe.  I will post details of when and where we will be going to see the movie.

Do You Have Mad (or even just slightly irked) Design Skills?

A while back I launched AllYourFlexAreBelongToUs.com, a Flex blog aggregator. So far, the sire is doing better than I could have hoped.  I am now ready to take the next step.  I want to offer "I am aggregated by...." buttons for my aggregatees ( I just now made that up) to add to their sites.  There is one big problem, my design skills are...how should I say this...pathetic.

If you have design skills that surpass a 4 year-old and are willing/able to help out, it would be much appreciated.  The only thing I ask is that the buttons stay true to the color scheme on the site.

What's in it for you?  Well, honestly, I don't have much to offer except my never ending gratitude and credit for designing the buttons.  But be rest assured your work will be viewed by millions thousands hundreds dozens of people.

If I happen to get more than one submission, I will probably put it to a public vote as to which one will be used.

Thanx in advance!

PagableArrayCollection Updated

A while back, I started working on a custom Flex component that would allow for easy pagination of data in an array collection.  I am happy to announce that I have made quite a few updates, the most obvious being that the PagableArraycolelction now supports sorting and filtering.

For more information, get out the project site on RIA Forge. 

How Do You Set Up Your Development Environment?

We were recently discussing setting up development environments in the #coldfusion channel on DalNet IRC.  This is a discussion that pops up form time to time, so I figured I would share how I set up my development environment.

I use Apache for my development web server, and for each project, I set up a new 'virtual host' so that each project can run form its own web root.  I really have no good explanation for doing this other than its the way I like running my projects.  I give each project a 'serverName' like blog.dev. This just helps me be aware of whether I am on dev or production, and makes it so I have to type less.

Then I set up a new entry in my HOSTS file for blog.dev and point it to 127.0.0.1.

To make editing httpd.conf and HOSTS easier to edit, I set up a project in Eclipse that points to my {apache root}/conf folder.  Inside of that project, I create a linked file to my HOSTS file.  Now from within Eclipse, I can edit my httpd.conf file and my HOSTS file.

I typically will structure my project so that I have a structure that looks similar to:

{projectRoot}
     flex-src (if its a Flex project)
    
support (this is where I put project documents, associated files, artwork, etc)
    
wwwroot this is the web root for my project, and where I point Apache to)

Obviously, as the project dictates, I will add other sub-directories. Also, when using SVN, {projectRoot} will typically be the 'trunk' of the repo.

So, how do you set up your development environment?

UPDATE: Someone asked in the comments for a way to restart Apache from inside Eclipse, well, thanx to Ant, that is very easy.  I attached an Ant file to this entry, you can get it from the 'Download' link below.  Drop this in your {apache root}/conf folder and when you want to restart Apache in Eclipse, right-click the file and choose 'Run As.. --> Ant Build' .  You may need to change the name of the service.  DISCLAIMER: This is offered as is and I make no warranties.  Offer void where prohibited.

easyMVC - A Lightweight Flex Framework

Not too long ago, I started working on a Flex project.  The application is not huge, but bigger than anything I have worked on to date.  One thing I wanted to do was find a Flex framework to use for the project.  I had looked at Cairngorm, Model-Glue: Flex and some others.

During my research, My good friend Jared clued me into a lightweight Flex framework, easyMVC, that Simeon Bateman was working on. It was nothing formal at the time, but Simeon had been using it on some projects.  I asked Simeon if he would be willing to share the framework, and he graciously did so.

I was, and continue to be, amazed at how easy it is to use, and more importantly, how lightweight it is (I think its only 8 classes).  It gets out of its own way, there is no perception of creating multiple files that do the same thing, there is no configuration file, it just works, and works well.  It was easy to get up to speed using it.  I decided to use the framework for my project.

After using the framework for a bit, I realized that the more I used it, the more I liked it.  The more complex the application became, the easier it was to use the framework, and, the more I liked it. In late November/early December, Simeon had mentioned to me that he was going to release the framework publicly and earlier this month made the announcement.

I am very happy Simeon has released the framework publicly as it means there will most likely be support for it in the future.  To date, I have not run into any issues where the framework did not allow for something I needed to do.  I am not saying its perfect, just that I have not yet hit its limitations.

Just so everyone understands, I am referring to this easyMVC, not this EasyMVC. Unfortunately, the EasyMVC by Tom Bray was not one that appeared on my radar when I was researching frameworks, but it has been added to my list of stuff I need to check out.


Ping Me!

Following on the heels of Ray's, announcement, 'ping' is also now available for All Your Flex Are Belong To Us

To ping AYFABTU, all you need to do is set up your blogging software to ping :

http://www.allyourflexarebelongtous.com/ping.cfm?BURL={your blog URL}

Where {your blog URL} matches exactly as it is stored in the DB.  To find out the exact URL we are using, simply look up your blog on the Feeds Page.

AYFABTU Update

It seems that some people have been taken aback by the length of the domain name, AllYouFlexAreBelongToUs.com, for the new Flex blog aggregator.  Well, thanks to Scott Pinkston, fear no more, you can now access ATFABTU by using flexbloggers.com as well.

Thanks, Scott!

New Flex Aggregator

I would like to announce that I am throwing my hat into the aggregator ring by launching All Your Flex Are Belong To Us.  This aggregator uses the same code base used in ColdFusion Bloggers and will, for now, aggregate blogs which discuss Flex (It's possible I may add blogs which discuss AIR as well).  The code was used with the permission and blessing of Ray Camden.

I would like to thank Ray and Dan Wilson for helping me come up with the name.  I know its a bit long, but I think it is easy to remember.

Doing 'screenshots' in Flex and sending them to ColdFusion

This weekend I was doing some research about capturing 'screen shots' of a Flex application, or even specific UI components, and passing the 'image' back to the server for processing.

While there are a few ways to do this, I am going to discuss the 'easiest'.  Using the JPGEncoder class packaged as part of the AS3 CoreLib on Google Code. Using this class to encode the data on the client side means that very little needs to be done server side to save the data as an image.

Its fairly easy to use this encoder to create binary data and pass it to CF.  I have set up an example here. If you enter some text into the text area inside the panel and click 'Send Image', Flex will create a JPG of the panel and send it off to CF.

Here is a look at some of the code, you can also view the source from the Flex application.

First, I import the JPGEncoder class. I store a lot of AS libraries and components in one location and add them to the 'source path' of my application.

import com.adobe.images.JPGEncoder;

Next, I create a method that converts a UI component into BitmapData.

private function getBitmapData(target:UIComponent ) : BitmapData        {
            var bitmapData:BitmapData = new BitmapData(target.width, target.height);
            var matrix:Matrix = new Matrix();
            bitmapData.draw(target, matrix);
            return bitmapData;
        }

As you can see, this method can take any UI element as an argument. This method returns the bitmap data of the UI element that was passed in.

Next, I create a method that handles calling the above method, and then sends the result to ColdFusion:

private function sendImage(target:UIComponent):void{            var bitmapData:BitmapData = getBitmapData(target);
            var jpgEncoder:JPGEncoder = new JPGEncoder(90);
            var imgData:ByteArray = jpgEncoder.encode(bitmapData);
            imageService.saveImage(imgData);            
        }

This method also takes any UI element and uses it when calling getBitmapData(). It also creates an instance of the JPGEncoder class.  The '90' that is passed into the constructor of JPGEncoder is the 'quality' of the resulting JPG.

Next we need to create a<mx:remoteObject> to talk to ColdFusion.

<mx:RemoteObject id="imageService" showBusyCursor="true" destination="ColdFusion" source="path.to.cfc">    <mx:method name="saveImage" result="onResult(event)" />
</mx:RemoteObject>

The CFC itself is very simple, it contains 1 method whose only argument is the binary data that is our image.

<cfcomponent name="Image Service" displayname="Image Service" output="false">    <cffunction name="saveImage" access="remote" output="false" returntype="any">
       <cfargument name="data" type="binary" required="true" />
       <cffile action="write" file="c:\Temp\flex_image.jpg" output="#arguments.data#"/>
    </cffunction>
</cfcomponent>

You will see that inside the method all we do is a <cffile> to write the data to a file. 

Lastly, we need some code that will fire off this entire event inside our Flex application.

<mx:Panel layout="absolute" id="panel" title="My Title" width="400" height="400">        <mx:TextArea left="5" top="5" bottom="5" right="5"/>
    </mx:Panel>
    <mx:Text text="Enter some text in the text area above and click 'Send Image'" />
    <mx:Button label="Send Image" click="sendImage(panel)" />

In my online example I  have other code that will open a new browser window and show you the image you just captured.  You can view the source by right-clicking the application and slecting 'View Source'.

Using this technique, you can do a screen shot of your entire application, or just individual UI components.

More Entries

BlogCFC was created by Raymond Camden. This blog is running version 5.9. original design by tri-star web design