December 05, 2007
Encrypting Data in AIR
AIR applications often need to store credentials. Many web services out there require authentication, which means that AIR applications need a secure way to store sensitive data. I first ran into this issue when I wrote Salsa, an Amazon S3 client. Salsa needs the end user's public and private access keys for signing requests, but since both keys are long arbitrary strings that are almost impossible to memorize, I couldn't ask the user to enter them each time they wanted to use the application. And for obvious reasons, I couldn't store them in plain text. I needed a way to persist the user's credentials in way that would not allow other users or processes to access them.
This was back in days of AIR beta 1. The only option I had at the time was to encrypt the credentials myself using a pass phrase provided by the end user. Each time the user started the application, therefore, I had to prompt them for their pass phrase which I'd use to decrypt the public and private keys. If they lost their pass phrase, they had to reenter their public and private keys, as well as enter a new pass phrase. From a usability perspective, this was not the experience I was after.
But then along with AIR beta 2 came the flash.data.EncryptedLocalStore API. There have been some small changes in M6 (the upcoming beta 3), but it's essentially the same. The EncryptedLocalStore APIs use DPAPI on Windows and the Keychain on Mac to encrypt arbitrary data and associate it with a specific OS user, AIR application ID, and publisher ID. That means applications can encrypt and store data that only the current user and the current application can decrypt. And the best part is that it's extremely easy to use:
// Writing encrypted information
var passwordBytes:ByteArray = new ByteArray();
passwordBytes.writeUTFBytes("secretPassword");
EncryptedLocalStore.setItem("password", passwordBytes);
// Reading encrypted information
var passwordBytes:ByteArray = EncryptedLocalStore.getItem("password");
var password:String = passwordBytes.readUTFBytes(passwordBytes.length);
To make using the EncryptedLocalStore even easier, my team has written a Preferences API on top of it which makes it extremely easy for applications to store either encrypted or non-encrypted user preferences using any serializable data type.
Whether you use our Preferences library or the EncryptedLocalStore directly, I really think the ease with which sensitive data can be encrypted and decrypted will encourage developers to build secure and user-friendly AIR applications.
Posted by cantrell at 07:18 AM. Link | Comments (7) | References
November 30, 2006
Fun with Flex Data Binding
I'm working on a new Apollo application, and I've been having some fun with data binding in Flex. In case you haven't used data binding yet, it is simply a way to bind an object to a component so that changes to that object are automatically picked up by that component, and the component automatically updates itself appropriately. Here's a simple example (not valid MXML, but you get the point):
[Bindable]
private var labelText:String = "This is a label";
<mx:Label text="{labelText}"/>
Now that labelText is bound to the label component, anytime the labelText variable changes, the text of the label automatically changes, as well.
Ok, that's a basic example. Here's a more interesting usage:
[Bindable]
private var items:ArrayCollection;
<mx:Label text="You have {items.length} items."/>
All I'm doing in the example above is combining bound data with a static string so that the label will always show the current number of items in the ArrayCollection. The beauty of data binding is that is saves you the trouble of updating components manually when certain events occur. You just focus on the logic of your application (adding and removing items from the ArrayCollection, in this case), and the label just takes care of itself.
Here's a slightly more interesting example:
<mx:TextInput id="myInput"/>
<mx:Button label="Do Something" enabled="{myInput.text.length > 0}"/>
This is an example, I'm binding an expression to a component attribute. The length property of the text input is bindable, so whenever it changes, the expression that I've bound to the enabled attribute is evaluated. If the length is greater than zero, true is returned, and the button is enabled, but if the length is zero (meaning nothing has been typed into the text input), the button automatically disables itself.
Let's take this one step further:
private function isButtonEnabled(someString:String, itemLength:uint):Boolean
{
if (...) {
myButton.label = "I'm enabled!";
return true;
} else {
myButton.label = "I'm disabled.";
return false;
}
}
<mx:Button id="myButton" enabled="{isButtonEnabled(someString, items.length)}"/>
In this example, I appear to be binding a function call to the enabled attribute of the button, but in fact I'm actually binding someString and the length property of items to the button. Whenever either changes, the entire expression is evaluated, which causes my function to be called. The arguments of my function call are basically just an arbitrarily long list of objects that my button may be interested in, and may not even be used in the function itself to decide what to do or return. Another advantage of this approach is that my function may do more than just return true or false. I can change the label of the button, or do any number of other things that are appropriate for the current state of the application.
There are a lot of other fun things that can be done with data binding, but I'm not going to go any further because I haven't decided where to draw the line yet between using data binding to its full potential, and abusing it. That said, if you have any good data binding tips or tricks, I'd love to hear them.
Posted by cantrell at 10:17 AM. Link | Comments (15) | References
September 22, 2006
Integrating Perforce with Flex Builder
Personally, I'm a Subversion fan. I started off using CVS for version control many years ago, then moved to Subversion, and have since been perfectly happy. But the Apollo team (along with most other teams at Adobe) uses Perforce, so I've been having to adapt. I actually like Perforce in general, but there are two things that really bother me:
- I don't like how you have to check files out (or add them to a changelist) before you can edit them. It's really annoying to stop what you're doing, switch to the P4Win client, and add a file to a changelist every time you want to edit it. It really interrupts my workflow.
- The P4Win client is kind of slow, and not the most intuitive and usable interface I've ever used. And that little jogging P4 icon was certainly an interesting choice.
Anyway, enough complaining. I decided I needed to make working with Perforce easier, so I tried installing the Perforce Eclipse plugin into Flex Builder 2, and was pleased to discover that not only does it work fine, but it really makes working with Perforce much easier and much more efficient. Now, when I want to edit a file, I can add it to a change list right form Flex Builder with a single click.
You can find out how to install the Perforce plugin here. To start using Perforce from Flex Builder, right click on a project, go to "Team", and select "Share project...". In the port field, enter the server and port in the format "server:port" and you're all set.
Posted by cantrell at 11:00 AM. Link | Comments (5) | References
March 01, 2006
Free, Open-source ActionScript 3.0 Libraries
We just released a set of free, open-source ActionScript 3.0 libraries to help get people going with the Flex Builder 2 beta. The libraries include the following projects:
- corelib. Several basic utilities for MD5 hashing, JSON serialization, advanced string and date parsing, etc.
- FlexUnit. A unit testing framework for Flex and ActionScript 3.0 applications based on JUnit.
- Flickr. A wrapper for the entire Flickr API.
- Mappr. A wrapper for the entire Mappr API.
- XML Syndication. Libraries for easily parsing all versions of RSS and Atom.
- Odeo. A wrapper for the entire Odeo API.
- YouTube. A wrapper for the entire YouTube API.
All the libraries are well documented and come with unit tests. You can download the source and/or just the SWCs, and do anything you want with them (the license is very liberal). All I ask personally is that you build something cool and send me the link.
We built a pretty nice mash-up called "Flow" using five of the seven libraries last week. Kevin Lynch showed it during the Flashforward keynote, and we should be releasing it (along with the code) within the next week or so.
Posted by cantrell at 10:48 AM. Link | Comments (4) | References
January 31, 2006
Flex Beta 2 and Free Flex SDK
It's all true. We've decided to release a free version of the Flex SDK. We haven't decided exactly what's going to be in it yet, but at a minimum, a compiler and the framework -- everything you need to build Flex 2 applications. We're also going to release a free version of Flex Enterprise Services that will be limited by the number of connections it allows, and will only run on a single server. Of course, Flex Builder 2 and the full version of Flex Enterprise Services 2 won't be free, but now anyone will be able to get started building Flex 2 applications at no cost whatsoever. This is all we really know at this point, but I'll post more details when I have them.
Also, Flex Builder 2 and Flex Enterprise Services 2 will go into public beta tomorrow, so get ready. Some of the new features include:
- View source support. If you want to share the source of your app, just enable the view source option when publishing, and Flex Builder 2 will automatically generate beautifully formatted source code for all the world to see along with a "View Source" option in the context menu. This is amazingly slick.
- Player detection.
- History management.
- Automatic import organization.
- Code collapse.
- Outline view.
- Tons of other stuff.
If you're still getting up to speed on Flex, I made a post the other day entitled "Clarifying the Term Flex" which describes in detail all the different components of Flex. I'll let you know when the beta is available for download, or you can just keep an eye on Adobe Labs (rss).
Posted by cantrell at 03:21 PM. Link | Comments (11) | References
January 19, 2006
Clarifying the Term "Flex"
I've noticed some confusion out there around the term "Flex". The term has evolved as our technology has evolved, and actually means something very different now than it did even just a few months ago. If you're a little confused about what we mean when we say Flex or Flex 2, this should clear things up.
I've decided to break this post down into two sections: Initial Flex Products, which describes how we started off using the term Flex, and Current Flex Products, which describes what Flex means today.
Initial Flex Products
- Flex 1.5: Flex 1.5 is probably what most of you think of when you think of Flex: an enterprise level presentation server. You write MXML, move it over to a server, and Flex compiles the MXML into a SWF, and serves up your application's presentation layer. You can compile your MXML "off-line" and just copy the resulting SWF over to your server, as well. Once your Flex application is running on the client, you can use web services or AMF to communicate with the server.
- Flex Builder 1.5: Flex Builder 1.5 is an authoring environment for Flex 1.5. It is based on the Dreamweaver code base, and gives you things like design and code view, syntax highlighting, code hinting, and application preview.
Current Flex Products
- Flex 2: Flex 2 is an umbrella term which refers to all the technologies in the Flex 2 product line including the Flex Framework, Flex Builder 2, and Flex Enterprise Services 2.
- Flex Framework 2: With the next generation of Flex technology, we have decoupled the framework from the products themselves. The Flex Framework consists of MXML (an XML-based language for declaratively building your applications), class libraries, components, containers, and effects. The Flex Framework can be used to build and style Flex applications without a server or any particular IDE. In fact, all you actually need to build Flex applications is the Flex Framework and the Flex compiler, both of which can be used on their own. Find out more about the Flex Framework here.
- Flex Builder 2: Flex Builder 2 is an entirely new product, and has almost nothing in common with Flex Builder 1.5. Flex Builder 2 is a brand new RIA IDE built on top of Eclipse, and is the easiest and most powerful way to build Flex applications. Flex Builder 2 makes developing Flex applications much simpler with features like an integrated compiler, code hinting, debugging, design view, source control system integration, and tons of other features. It will be available as both a standalone application, and as an Eclipse plugin that you can use with your existing Eclipse installation. Find out more about Flex Builder 2, and download an alpha release, here.
- Flex Enterprise Services 2: Flex Enterprise Services is basically the next generation of the Flex 1.5 server, but with tons of new functionality like automated testing, enterprise messaging support (which provides a publish/subscribe messaging infrastructure), and the Flex Data Services, which automatically synchronizes data manipulated locally with data on the server. Find out more about Flex Enterprise Services 2 here.
Other Flex-related Technologies
- Flex Charting Components 2: The Flex Charting Components 2 are a new set of customizable Flex components which provide very slick data visualization capabilities. Think of them as an extension to the Flex Framework. You can use them with Flex Builder 2 and Flex Enterprise Services. Find out more about the Flex Charting Components 2 here.
- Flex Compiler: Although Flex Builder 2 and Flex Enterprise Services both have the Flex compiler built in, it can also be used outside of either product. The compiler can be used for compiling MXML applications or ActionScript projects from the command line. Find out more about using the Flex compiler and Flex framework from the command line here and here.
- ActionScript 3: ActionScript 3 is the core of the Flex Framework. Although the syntax is similar to ActionScript 2, it is more object-oriented, more strongly typed, and because it executes inside a brand new virtual machine, it is much faster than ActionScript 2. ActionScript 3 is fully compliant with the ECMAScript 4 proposal (the standard JavaScript 2.0 is based on), and includes things like E4X and regular expressions. Find out more about ActionScript 3 here.
- Flash Player 8.5: Flash Player 8.5 is the newest version of the Flash Player, and is still in alpha. It is the client runtime for Flex 2 applications. The biggest addition to Flash Player 8.5 is the ActionScript 3 virtual machine. Find out more about Flash Player 8.5 here.
If you have any Flex related questions, or if anything in this post isn't clear, let me know.
Posted by cantrell at 09:55 AM. Link | Comments (19) | References
January 17, 2006
A Ruby Script for Compiling Flex Applications
There have been a lot of posts recently about how to compile Flex applications and ActionScript projects from the command line (on Windows, Mac, and Linux). Mike Chambers has a nice summary which points to all the information you need to get going, and has a bash script which wraps the mxmlc compiler to make compilation easier.
I have some specific compilation needs, however, so I decided to write a Ruby script to wrap the mxml compiler (I'm not a huge fan of bash once my scripts reach a certain level of complexity). Once you have the Flex environment set up, just download the script, make sure it's in your path, configure it, and you can compile like this:
% mxmlc.rb MyApplication.mxml
The script has the following flags:
- -h Help. Prints out this help message.
- -t Tail. After compilation, tails the file specified by the TAIL_PATH variable. (Useful for debugging your application.)
- -o Open. After compilation, opens the generated swf in the application specified by the OPEN_APP variable. (This should probably be something like 'firefox' or 'safari'.)
- -s Show. Show the compilation command rather than actually running it. Useful for debugging if it's not working like you expect it to.
- -c Clean. Removes cache files before compilation so you compile the project completely from scratch.
Before running the script, you have to configure it by defining the following variables at the top:
- FLEX_PATH: The path to your Flex library installation.
- AS_LIB_PATH: Path to your ActionScript libraries. In other words, your classpath. You can specify multiple directories by separating them with a ':' character. You can also add a '$' character anywhere in any of the paths which essentially acts like a wildcard. For instance, if I added the directory /Users/cantrell/projects/$/src/actionscript, then the script would iterate through all the directories in /Users/cantrell/projects and add all those directories, plus /src/actionscript to the classpath. It's an easy way to include an entire source tree with one path. (If the generated directory doesn't actually exist, the script automatically leaves it out.)
- TAIL_PATH: The path to the file you want to tail if you pass in the -t flag.
- OPEN_APP: The application you want to open the resulting swf file in if you pass in the -o flag.
Let me know if you have any problems getting it to run. It was written and tested under Ruby version 1.8.2 which should already be installed on your Mac. To get the alpha version of the Flex Framework and the compiler, check out Flex Builder 2 on Adobe Labs.
Posted by cantrell at 08:59 AM. Link | Comments (3) | References
January 09, 2006
ActionScript 3.0 Presentation and Examples
Back in November, Danny Dura and I did a small world tour to talk to our international communities about ActionScript 3.0. Danny did Europe, and I did Asia. We put together a PowerPoint presentation (which you can view here), and several good code examples (which you can download here). The presentation covers:
- Regular Expressions.
- E4X. The new and very simple way to create, parse, and query XML in ActionScript 3.
- ExternalInterface API. Allows your Flash content to communicate with its container (usually the HTML page via JavaScript) without any additional libraries.
- File upload. Shows how to upload a file using Flex and save it on the server using ColdFusion. (File upload is actually already available in Flash 8.0, but this is a Flex 2 example).
- Data types. Lists all the ActionScript 3.0 data types and their default values.
- Operators. Demonstrates some of the ActionScript 3.0 operators.
- Packages. Demonstrates how packages work in ActionScript 3.0.
- Rest arguments. ActionScript 3.0 supports a concept of "rest arguments" which you allows you to make some argument required, and also handle an arbitrary number of additional arguments.
- Proxy. The flash.util.Proxy object is a more powerful version of __resolve.
- Reflection. Shows how to introspect ActionScript 3.0 classes.
- Timer. Shows how to execute code at a specified interval.
- The new display list API.
To run these examples and build your own Flex 2.0 applications, you'll need to grab the Flex Builder 2 alpha from Adobe Labs.
Posted by cantrell at 10:10 AM. Link | Comments (0) | References
November 10, 2005
CFEclipse and Flex Builder 2: Happy Together
I now do all my Flash development in Flex Builder 2. No exceptions. But I still use another installation of Eclipse for other types of development (ColdFusion, Java, HTML, JavaScript, etc.). Yesterday, I ran into a situation where I needed to embed a small Flex application in a custom HTML page, so tried installing CFEclipse into Flex Builder 2, and it seems to work perfectly. It's not guaranteed to work, and I supposed it could break in the future, but for now, I'm a very happy developer.
Update: I should qualify that I'm talking about the standalone version of Flex Builder 2. The plugin version will definitely work with CFEclipse.
Posted by cantrell at 09:56 AM. Link | Comments (5) | References
October 10, 2005
Video of Flex Announcement at Web 2.0
Although you've probably already seen the Flex 2.0 product family announcement, you can now see a video clip of Kevin Lynch actually delivering the official announcement at Web 2.0. Mike Chambers got Kevin's entire presentation on tape. It's only about 15 minutes long, but Kevin packs in a ton of good information, including building a very nice little application using Flex Builder 2 (Zorn) in only about 5 minutes. The clip is available as Flash video both on Mike's blog and on Google Video. If you get seasick, brace yourself for about the first 30 seconds, but after that, it stabilizes.
Posted by cantrell at 11:33 AM. Link | Comments (3) | References
October 05, 2004
Non-commercial Flex Licenses Now Available
Flex just became much more accessible. If you're a student, educator, or if you run a non-commercial, non-institutional website, you can now use Flex for free in a production environment. From Macromedia's site:
This software license will enable individuals, including students, technology educators and individual developers to build and deploy Flex applications at no cost (except for a small shipping and handling fee). Participants also receive 1 license of Macromedia Flex Builder, the Macromedia IDE for Flex.
Find out more (including exactly who qualifies) by reading the Flex FAQ.
Posted by cantrell at 10:33 AM. Link | Comments (4) | References
August 23, 2004
Flex Builder (aka Brady) Goes Live
If you're doing Flex development, you will be happy to hear that Flex Builder -- the Flex IDE we've been calling "Brady" -- is now live. There's tons of information about Brady on the site, which I'll link to below, but I'll give you the lowdown here to save you a few clicks.
Flex Builder is an IDE for developing Flex applications. It doesn't just do MXML syntax highlighting and provide things like tag insight, though; it's actually very tightly integrated with the Flex server and really streamlines Flex application development.
As you might have guessed, Flex Builder is for Flex developers, and really specializes in and focuses on Flex application development. It's not a general purpose IDE like Dreamweaver or Eclipse.
Flex Builder comes with Flex. The Flex Builder trial comes with the Flex trial, and five licenses of Flex Builder come with every Flex license. (If you already purchased Flex, don't worry -- you can still get your Flex Builder licenses. See links below.)
You don't need Flex Builder to build Flex applications. You can keep using Dreamweaver, Eclipse, Emacs, Vim, or whatever you like to use. If you're using WIndows for Flex development, though (Flex Builder is only available on Windows), you might want to give it a try. I saw a demo of it last week, and it will really make Flex developers' lives easier.
That's Flex Builder at a high level. For more information, see:
- The Flex Builder Product Page
- Flex Builder FAQ
- Introducing Flex Builder
- Flex Builder Videos
- Flex Features
Posted by cantrell at 10:20 AM. Link | Comments (1) | References
August 05, 2004
Excellent Review of Flex
And by "excellent", by the way, I don't mean that it's unconditionally glowing. I mean that it's thorough, accurate, and objective.
In Peter Ent's review of Flex, he discusses the processes and challenges of building five very different applications using Flex with J2EE back-ends. For each application, Peter describes the project, provides links to screenshots and zip files containing the source code, and discusses the benefits and challenges of using Flex (along with other technologies like Flash Communication Server, and even the charting components from B-Line Express). At the end he provides a short analysis of Flex as an alternative to JSP, and summarizes the processes of coding in MXML, debugging Flex applications, and using style sheets with Flex. And, of course, he has a few comments on Flex documentation, as well.
This is one of the most honest, straightforward, and comprehensive reviews of Flex I've seen so far, and it's obviously written by someone who knows the technology he's working with. (It also doesn't hurt that it's relatively short and very easy to read, as well.) If you looking for a detailed, objective perspective on Flex technology, this is it.
Posted by cantrell at 10:00 AM. Link | Comments (0) | References
July 14, 2004
Flex 1.0 Updater 2 Is Live
Just wanted to mention that the Flex 1.0 Updater 2 just went live. Lots of good stuff, according to the release notes. If you use Flex, get this update!
Posted by cantrell at 05:54 PM. Link | Comments (0) | References
June 18, 2004
Curious About Brady?
Macromedia just published a new Logged In article with a lot of great information on Brady, Macromedia's new Flex IDE (which just entered final beta). It contains some pretty detailed descriptions, and several good screenshots. Here's a little taste:
Brady is the Macromedia IDE for Flex application development. Designers and developers can be more productive building Flex applications through tight integration between the IDE and the server. Developers can learn MXML and type code more quickly and accurately using Brady's code hinting feature. More visually-oriented programmers can use the drag-and-drop Design view to quickly lay out Flex interfaces and style them using CSS....
Posted by cantrell at 09:53 AM. Link | Comments (3) | References
April 09, 2004
Changing The Flex Preloader
I've seen a few people ask if there is any way to turn off the default preloader in Flex applications. You can do so using the "usePreloader" attribute of the Application tag, like this:
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" usePreloader="false">
But why turn it off? It's so nice! I can understand wanting to customize it, though, which you can do using the "preloader" attribute of the Application tag. For more information on customizing the Flex application preloader, search the Flex LiveDocs for the term "preloader" and you'll get all the information you need.
Posted by cantrell at 12:17 PM. Link | Comments (1) | References
April 01, 2004
Flex Trial Pricing for International Customers
There was a problem with the Macromedia online store which was causing international customers to be charged too much for the Flex trial CD. The issue has been resolved, so the price should once again be $8.99. Apologies to those who were affected. Please let me know if you have any other problems.
Posted by cantrell at 12:32 PM. Link | Comments (1) | References
March 29, 2004
Flex 1.0 is Live
Flex 1.0 has been released! There's no sense in me discussing it extensively here -- everything you will want to know is outlined on the Flex product page on Macromedia's website. I'll just say that I've been playing with Flex a lot for the last few days, and it's really amazing technology. I'm in Newton right now, immersing myself in Flex, which I'm loving!
Posted by cantrell at 09:49 AM. Link | Comments (3) | References
December 12, 2003
Flex - A Third Party Perspective
You've probably read all there is to read about Flex on Macromedia's site, and if you were at MAX, you heard plenty of discussion and saw plenty of demonstrations. Now check out what Java Boutique has to say about Flex.
Posted by cantrell at 09:46 AM. Link | Comments (4) | References
November 17, 2003
Royale is Now "Flex"
Royale is now officially "Macromedia Flex," and is now officially in beta (interested in joining?). And Macromedia has officially hired Christophe Coenraets as the official Flex Evangelist. Lot's of official announcements, which you can read about in an official article on DevNet.
Now I'm officially off to MAX.
Posted by cantrell at 08:20 AM. Link | Comments (8) | References