« December 2005 | Main | February 2006 »
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 3:21 PM. Link | Comments (11) | References
Programmatically Determining a Site's Language
I was having a conversation with a couple guys the other day about data aggregation, and the topic of language came up. They wanted to know how you can programmatically determine what language a site is written in (language as in spoken and written language, not computer language). Off the top of my head, I guessed one could uncover clues in the site's HTTP headers, character encoding, or by geocoding the site's IP address.
It turns out to be a harder problem to solve than I initially thought. HTTP headers are really no more help than a site's character encoding which really isn't much help at all since UTF-8 can pretty much encode any language there is. And geocoding an IP address is really nothing more than a hint for all the regular reasons geocoding IP address doesn't always work, and for the additional reason that a server being in a particular country doesn't really tell you anything about the language the sites on the server are written in (I used to live in Japan, but never posted a single thing in Japanese).
I did a little research, and it looks like folks like Google use very complex techniques for determining a site's language like comparing characters and words against known sets of characters and words in a database. This seems like a reasonable approach, but not one that I could implement in a reasonable amount of time (like a couple of hours), so I did what I always do when faced with a very complex problem: I looked for an obvious and simple solution.
What I eventually decided was that the sites out there with the most content, and content which is updated most frequently (and therefore are the most interesting sites to index) actually almost always tell you what language they are written in through their RSS or Atoms feeds. Of course, a research paper isn't likely to have an RSS feed, but most news sites and just about all blogs certainly do.
I tested the theory by writing a Ruby script that crawls sites and their feeds looking for things like xml:lang attributes and other language-related tags. I ran the finished product against a sample of 50 non-English blogs from MXNA and determined that the technique is about 60% accurate. Not great, but not too bad, either. I also rediscovered a lesson I'd already learned many times over when writing aggregators, which is that you should never trust data you don't control since all but one of the sites that my script got wrong actually lied and claimed to be a language it wasn't (in every case, they claimed to be English rather than the language they were actually written in). How do I explain the fact that about 40% of blogs seem to lie about their language? I'm sure it's an innocent mistake. Most people don't really know much about how RSS and Atom work, and just trust their blogging software to do the right thing. Even if they write the software themselves, they probably don't really know what all the RSS/Atom tags actually mean. RSS is sort of the new HTML: as long as it mostly works, it's good enough for most people.
Like I said, the script works by crawling sites and their RSS or Atom feeds. If you're interested in the source, you can grab it here. I also threw together a CGI wrapper for it, so you can test it out online yourself here. If you're new to Ruby and don't feel like decoding all the regular expressions, here is a brief description of how it actually works.
- You give it the URL of a blog or other news site which you assume has an RSS or Atom feed, and it grabs the source.
- It checks to see if the site's source itself gives any clues about the language it's written it through meta tags.
- If it doesn't find any clues in the site itself, it looks for link tags referencing RSS or Atom feeds. If it doesn't find any, it searches for any links in the page that seems like they might references an RSS or Atom feed.
- Assuming it has found one more links to probable feeds, it resolves the URLs, grabs the source, and looks for language-related attributes and tags in the feeds.
- Finally, once it finds what it thinks is a language code, it simple converts it into an actual language name.
Some lessons learned:
- Never trust data that you don't own unless absolutely necessary. This is an important lesson in data aggregation. Don't trust dates, languages, or even things like character encodings and categories. Determine as much as you can yourself, and be skeptical of the rest. As C3PO says in The Empire Strikes Back, "R2D2, you know better than to trust a strange computer."
- If you have a non-English blog, check your feed and make sure you're not masquerading as English. I knew my script wouldn't be 100% accurate, but I was really surprised to discover that almost %40 of non-Enligh blogs claim to be written in English.
- Use link tags to point to your site's feeds to allow people to "auto-discover" them. You can add a link tag to the head section of your site which references your feeds which allows things like Firefox, Safari, future versions of IE, aggregators, and rogue Ruby scripts to find your feeds more easily.
- 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.
- 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.
- 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.
- -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.
- 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.
- 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.
Posted by cantrell at 10:24 AM. Link | Comments (1) | 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
Current Flex Products
Other Flex-related Technologies
If you have any Flex related questions, or if anything in this post isn't clear, let me know.
Posted by cantrell at 9: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:
Before running the script, you have to configure it by defining the following variables at the top:
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 8:59 AM. Link | Comments (3) | References
January 9, 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:
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 | References
January 5, 2006
Flash and Ajax: Happy Together
Adaptive Path recently released their Flash/JavaScript Date Slider under a Creative Commons License. It's a very slick component that they use with Measure Map for visually selecting date ranges, and which shows excellent interoperability between Flash and JavaScript. It uses the JavaScript / Flash Integration Kit as the bridge between Flash and JavaScript, and I think integrates very nicely into HTML/Ajax applications. From the Date Slider site:
The date slider is a Flash visualization that Measure Map uses as one way to navigate the site. We are happy to provide a version of this date slider to the public... SWF version with the ability to customize the look & feel of the slider as well as the location and name of the XML file.
What I really find interesting about this project is that it is a standalone component which integrates Flash and Ajax very seamlessly, and therefore tends to blur the line between the two technologies. Too often I read about the "Flash vs Ajax" debate when the reality is that Flash is very Ajax friendly, especially with the new ExternalInterface object.
Posted by cantrell at 8:55 AM. Link | Comments (3) | References
Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy (updated 07-14-2009).