January 2009 Archives

Clever Flex Binding With Ternary Operators

| 7 Comments

While I have known of the ternary operator for years, in the past, I have found it uselessly obtuse and preferred to use the classic "if" statement. In my mind, the two were equivalent. I have just recently discovered that this is in fact untrue, as far as Flex is concerned. So very untrue indeed. Read on and I will explain why I have discovered a new-found appreciation for the long lost operator.

The ternary isn't an if, no "ands or buts"

To me, the main reason not to use the ternary operator was if the two were equivalent, the clarity of the "if" trumped its brevity. Besides, it looked a little too much like PERL (the "Language of a thousand operators").

The following two statements are indeed equivalent:

Statement 1.

if (value1 == value2) {
value3 = true;
} else {
value3 = false;
}

Statement 2.

value3 = (valueA == valueB ? true : false);

OR statements using the ternary operator

Just for fun, it is also possible to write a one-line "or" statement using a ternary operator.

e.g. (if a is true or b is true, c is true, otherwise c is false)

c = (a ? true : b ? true : false);
is equivalent to:

if (a || b) {
    c = true;
} else {
    c = false;
}


Where Bindings Come In

So far, I haven't covered anything particularly earth-shattering, however, if you're a Flex developer, you'll appreciate how much you depend on the maintainability and brevity of using binding statements in your Components (i.e. the MXML statements inside curly brackets e.g. "{bindMe}"). Sometimes, you'd love to, but Flex won't allow you to conditionally bind a value.

Despair not. Although if/else statements aren't allowed inside a binding statement, a ternary expression is allowed. That means that you can now write conditional binding expressions, rather than having to take the more complex statements that you'd like bound and putting them into a function, add on a bunch of event-handling code, wasting precious moments out of the prime of your life.

e.g.

<mx:text text="{data as String}"
toolTip="{(data as String).length > 20 ? data as String : null}"/>

This statement allows me to display a bound toolTip value if the string inside the Text Component is longer than 20 characters. Otherwise, it shows no toolTip.

...now let that sink in.

What it means is that you can create dynamic bindings with conditional "smarts" in them. If you're anything like me, that's pretty freaking sweet. Not too shabby for an operator that I personally had condemned to the slag heap of obscurity.


Citrix + Remote Desktop Keyboard Shortcuts

| 6 Comments
In one of my current projects involving the development of a custom LiveCycle workspace in Flex, I've had the (dis)pleasure of developing remotely on a PC at the client's site using Citrix ICA and Remote Desktop. (Don't ask why but feel free to sympathize a little.)

One thing I've found useful during my "out of body" development experience has been the use of hotkeys / keyboard shortcuts. They are the reason that I am still sane today.

The most useful has been the CTRL-ALT-BREAK shortcut to go to full-screen mode. After the sheer torment of trying to code, run and debug a complex application in a tiny window with both horizontal and vertical scroll bars, being able to force the remote session to full-screen mode was like a revelation.

Here are a few more shortcuts that I use often:

  • ALT-HOME - Pulls up the remote OS' "Start Menu"
  • CTRL-ALT-END - Equivalent to a CTRL-ALT-DEL
There are many more to learn at this useful reference (EDIT: this link has died, I have however re-posted the original list here). Please spread it around. I'd like to think I helped spare people the grief that I've had to go through.

Flush Flash Aggravation with a Fresh Flex Aggregator

| No Comments
My apologies for the cheesy title. I'm work-loaded and sleep-deprived.

If you are "into" Flex/Flash development, I strongly suggest that you take time daily to check out what's new on this Flex blog aggregator: All Your Flex Are Belong To Us (RSS feed here)

From what I've found, it's by far the best non-Adobe point of access to (~95%) Flex-related blog postings. There's new stuff on there every day, and I can't begin to summarize the useful and/or thought-provoking posts I've come across there.

I've submitted a request to be included in the feed. Here's hoping my request is granted. T'would make it a lot easier to get people to visit this space, that's for sure. I only have so many family members, after all.

Adobe and Amazon Team Up on "Sandbox In The Sky"

| No Comments
"Sandbox in the Sky"... sounds like a Miyazaki movie, but it isn't. It's one phrase aptly used to describe a new project underway at Adobe and made possible with help from Amazon Web Services.

The two tech giants have partnered in creating a new "cloud-ish" LiveCycle ES development environment for use by members of the Adobe Enterprise Developer Program. This tool promises to allow developers to gain access to fully-configured LiveCycle development environments with the click of a button (must be a very big button).

The service is called "Adobe LiveCycle ES Developer Express" and leverages Amazon's "Elastic Compute Cloud" (aka EC2), as well as Amazon's S3 (aka "Simple Storage Solution") data service offering.

I haven't yet seen this running, so I can't comment on the performance or how reasonable it is to use, but kudos to Adobe and Amazon for being so ambitious. I can just imagine how many integration headaches they've had to go through to get this going... especially considering how much of a steaming load of grief LiveCycle can sometimes be to get running locally with anything but a vanilla configuration.

Check out the press release here.


About this Archive

This page is an archive of entries from January 2009 listed from newest to oldest.

December 2008 is the previous archive.

February 2009 is the next archive.

Find recent content on the main index or look in the archives to find all content.