Saturday, December 30, 2006

onFrameEnter, onFrameEnter, onFrameEnter, onFrameEnter...

If a component is visible (possibly even when it isn't visible?) and you are hooked into the onFrameEnter event it will fire continuously at a regular interval, even though nothing is happening. I found this very frustrating when trying to put together a little Flex flash player (which is the cause of most of the problems I ran into). I had wanted to display the current frame being played and thought using theonFrameEnter event would work. This was a very unexpected behaviour, though I'm sure there are reasons for it. This ties into a couple other problems I had, which will be coming up shortly.

Flex 2 Annoyances

I've been using Flex 2 for a couple of weeks now and it is really a powerful and fairly easy to use framework. The language (Actionscript 3) used for scripting is very easy to pickup (I'm coming from mainly a Java background) and the Flex Builder IDE helps get a UI together in a snap. There are a few things that I have found very annoying with this new technology though so I thought I'd do a couple posts on the problems I've had so far and any solutions I've come up with. More to come.

Tuesday, December 12, 2006

Rails Helpers: CaptureHelper and content_for

A little bit of ruby goes a long way. There's a whole lot of ruby out there though, especially in rails, so finding that little bit is sometimes hard. I just wanted to point out one of those really neat features of rails that I've never heard about until now; capture_for. This piece of magic is part of the CaptureHelper and can be really useful in a bind.

Here is a chunk of RDoc from the Rails API:

layout.rhtml
  <html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
<head>
<title>layout with js</title>
<script type="text/javascript">
<%= yield :script %>
</script>
</head>
<body>
<%= yield %>
</body>
</html>

view.rhtml
  This page shows an alert box!

<% content_for("script") do %>
alert('hello world')
<% end %>

Normal view text

This will defiantly help you out if you're using layouts (which you probably are) in rails because it lets the view page change a portion of the layout if it needs to. I found this really useful when I needed to try and load up a swf file in one of my views and wanting to do some browser/flash detection when the view was loaded. I didn't want the detection to happen on all the pages that used the view, but I needed it to happen when the page was being loaded. Rails helper to the rescue!

layout.rhtml
  <html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en">
<head>
<title>layout</title>
</head>
<body <%= yield :script %>>
<%= yield %>
</body>
</html>

view.rhtml
  This page detects flash!

<% content_for("script") do %>
"onLoad='detectFlash()'"
<% end %>

Normal view text


See that? You can even yield inside an open html tag (this is pseudo code, but should work). On all the other views that use layout.rhtml nothing happens, you just get a normal . When view.rhtml is shown "onLoad='detectFlash()'" is inserted into the body, and run, detecting the flash version before the page loads. This was something that I thought was going to be a serious problem to do, but rails makes it super easy.

There are all kinds of other goodies in the rails classes/ActionView/Helpers package, I would recommend checking them out because there is probably something there to help you out. Oh ya, if you actually need to detect the flash version of someones browser Dreamweaver spits out a nice script that will do it for you. If you need that let me know and I can post it.

Friday, December 8, 2006

Introduction to Adobe Flex 2 and ActionScript 3

Just this week the company I work for (CleanCode) decided to put up a public blog on their webpage. I thought this was a great idea because there have been a couple things I had wanted to post to a blog but didn't really think I had enough to say to start my own. Well, that is until a day later when Jeff and I thought it would be a good idea to set up a group blog, now here we are. Anyways, I've been working with Flex 2 and ActionScript 3 a fair bit for a project at work so just put up a post on that blog about how I've been finding it, thought I'd give a bit of a rundown here and link to the post.

The CleanCode post can be found here (the following has some additional information).

Before I get into this I should really point out that this past week or so is the first time I've ever looked at anything Flash or ActionScript. I am mainly a Java developer, with some Ruby, Rails and C# thrown in for good measure. If I get anything wrong here please let me know because I am still learning and would appreciate the input. On to my post...

Flex 2 is basically Adobes solution to web development in the web 2.0 ajaxy world (yes, I used the word ajaxy and died a little inside). It is a framework built off of Flash specifically for application development, targeted at software developers. This is very different from the traditional Flash as it was mainly targeted to designers. Don't get me wrong, I'm sure lots of smart people out there have used Flash to build applications, but that's not really what is was designed for, Flex is.

Flex has everything we've come to expect from web platforms: visual designer, smooth interfaces and AJAX built in. To design your application you write MXML (or drag and drop components in the editor) and make the magic by scripting in ActionScript. Did I mention that the editor Adobe put together (Flex Builder 2) is built off of the Eclipse RCP? It is, which makes it cool. What makes it uncool is that Flex builder is missing a lot of the functionality that most people have come to expect from Eclipse, or any other full fledged IDE for that matter.

List of stuff it has:
  • Drag and Drop design view
  • Syntax Highlighting
  • Intellisense
  • Debugging
List of stuff missing:
  • Variable inspection
  • Auto Formatting
  • Refactoring
  • SVN integration
  • Plugin support
Okay, so I guess they have about half the stuff I want, but what is missing makes a big difference - especially when building off of a product with most of those features. I guess the big thing I find annoying is the price tag they put on Flex Builder, upwards of $500 which I think is a bit much for the functionality it provides. Good thing they have a 30 day trial.

I really do find Flex Builder to be a good tool to work with though, would like them to implement some of those features but the debugging and all the rest really makes a big difference.

Flex and the version of ActionScript (3) that comes with it are both new versions of flash going together with the new Flash Player 9. Actionscript and the Flash VM have been completely rewritten (still backwards compatible) and they are claiming it's at least 10x faster than the previous versions. Another great thing with Flash is the adoption rate of flash players, almost 40% of the population after 3 months. This means you have a web platform to develop against that almost everyone will have without having to worry about browser versions, javascript or other fun surprises (to a certain degree). That is defiantly a plus, not to mention the apps look very slick (Harley Davidson, Samples).

This isn't to say that Flex 2 is the greatest, it defiantly is not the best, simply another alternative. Actually, there is a lot of stuff that's been bugging me about it and I've hit a number of snags that I'm sure a lot of other people will be running into as well. I guess that means another post on common problems in Flex 2 and some of the solutions I've come across. Make sure to check out the other version of this post too, there are a couple screenshots in that one.

Technology, Ideas and Thoughts

The thing to do these days is to have your own blog. I'm not one to fight society, so here we are, this is my blog. Actually, I really don't think I have that much to say so this is going to be a shared blog between myself and a couple of friends who share similar (well, sometimes) interests.

Who are we?

Really, we're not much of anything yet. We all took, or are just finishing, Software Engineering at Carleton University in Canada and are now either working or in that in between stage with work and school. We all deal with a variety of technologies on a daily basis and thought it might be a good idea to share our experiences with the rest of the world. Hopefully some of the solutions we've come up with for various problems will be helpful to someone else, or maybe they can suggest a better way of doing things to us. Who knows, maybe we'll even come up with something original a couple original ideas too.

What's with the name?

Google-Steals-My-Thoughts. Not much to say here other than it seems like it has happened to each of us at one point, and probably most of the world. You know when you're sitting there, reading your feed and you think 'Wow, wouldn't it be cool if ____!!' Then you message a friend and tell them the idea, and wouldn't you know, he agrees with you! That's all well and good until two days later when Google comes out with the exact same service you were talking about. Pricks, stealing my thoughts.