Deep Linking with Flex 4 using Fragments

The objective of deep linking is typically centered on creating functions that either serialize the current state to the URL or deserialize the URL and use that information to change the state of the application. This makes it possible to bookmark a specific state of your Flex application. The main ingredient for this deep linking implementation is called a “fragment”. You’ve probably seen these used before in HTML or Javascript. A fragment is separated from the URL using the hash mark symbol (#). For example, fragments are used when anchoring items of an HTML web page. A “frequently asked questions” page is the first thing that comes to mind for me because there are so many FAQ pages on the web that list the questions at the top of the page and when you click on a question, the scrollbar jumps down to the respective answer for the question you clicked on. However, in Flex, you can use this same concept to tell your application what state it should be in or even the state of a specific component!
Note that when using URL fragments for deep linking, you actually want to keep the built-in history management off, otherwise it will interfere with fragment processing.

Step 1
Start by declaring three variables:
1) a reference to the Flex BrowserManager class,
2) a flag to signal that URL parsing is in progress, and
3) a variable to hold the title for the browser’s title bar.
public var browserManager:IBrowserManager;
private var isParsing:Boolean;
private var title:String;
Step 2
Now, you need to declare your states of your application if you haven’t already and place a listener for the enterState event. When the state changes, a call to updateURL will be made.

<s:states>
    <s:State name="Home" enterState="updateURL()" />
   <s:State name="About" enterState="updateURL()" />
   <s:State name="Services" enterState="updateURL()" />
   <s:State name="Store" enterState="updateURL()" />
</s:states>
Step 3
When the application loads, you’ll need to initialize the BrowserManager, and register two listeners, one for when the browser’s URL changes and the other for when the application’s state changes. Lastly, you’ll use the callLater() method of UIComponent to parse the URL. Note that this function is called on creationComplete of the Application tag.

private function application_creationCompleteHandler():void
{
   browserManager = BrowserManager.getInstance();
   browserManager.init("", "Home");
   browserManager.addEventListener(BrowserChangeEvent.BROWSER_URL_CHANGE, parseURL);
   callLater(parseURL);
}
Step 4
Now write the code for your parseURL() function. This function will be called whenever the BROWSER_URL_CHANGE event fires. The function parses the URL, and if fragments are found, it will change the title and state of the application accordingly.

private function parseURL(event:Event = null):void
{
   isParsing = true;
   var o:Object = URLUtil.stringToObject(browserManager.fragment);
   if (o.view == undefined)
      o.view = "Home";
   currentState = o.view;
   title = currentState;
   browserManager.setTitle(title);
   isParsing = false;
}
Step 5
You are now successfully updating the application from the URL! The next thing you need to do is update the URL from the application though. We’ll accomplish this with the function updateURL().

private function updateURL():void
{
   title = currentState;
   var fragments:String = "";
   var o:Object = {};
   if (currentState != "Home")
      o.view = currentState;

   fragments = URLUtil.objectToString(o);
   browserManager.setTitle(title);
   browserManager.setFragment(fragments);
}
And that’s all there is to it. Happy Flexing!
-Dan Orlando
Posted in ActionScript, Flex 4, RIA | Comments Off

seeking flex developers for high profile dashboard project

mockup of the iPad version of our flex dashboardWe have been working on a dashboard RIA at the Department of Energy since last December. The goal of the dashboard is to enable the government to track where all that recovery money is going, how and when it is spent, who is behind and ahead of schedule, etc. The project has gotten a lot of attention; over sixteen other government agencies have requested demos of the dashboard so that they might implement similar solutions.

The role of Anaara Media has been to provide the software architecture and development on this project. Recently the scope of the project has escalated and we are now seeking several top notch Adobe Flex developers to join us in this effort. If you consider yourself a ‘Flex Ninja’ and you’re interested please contact us at jobs at anaara dot com.

Here is are some more details regarding the project:

-it’s onsite in Germantown, Maryland
-there is opportunity for offiste work, after an initial couple weeks work can be 80% onsite / 20% offsite. If you extend beyond the initial contract (see below) and you’re not local, possibility for greater percentage of offsite work is very flexible
-candidates have to be U.S. citizens
-we are using: Flex 4, Robot Legs, AS3 Signals, Axiis, Degrafa, Flex Charting, and lots of custom components
-in depth knowledge of Flex 4 component life cycle highly desirable
-candidate should be comfortable using E4X and Regular Expressions
-candidate should be a fast learner…we are constantly pushing the envelope (on every project we engage, including this one)
-knowledge of/experience with printing in Flex would be great. We are struggling with the limitations of existing printing frameworks, and will probably wind up rolling our own or extending one of the current third-party frameworks
-initial contract for 2 – 4 months, renewable for a year or longer
-agile development environment
-development team of seven flex developers and one user experience designer (UXD)
-not your typical government project – agile process, weekly iterations, bi-weekly to monthly release cycles, and goal of six iterative releases between now and end of January. What we build is limited only by two factors – our own capabilities and ability to deliver on schedule. Yes, it is a bit intense, but that is where we shine.
-we’re looking for developers we can establish long-term relationships with beyond the scope of this particular project and contract
-we pay for time our developers spend blogging – we believe in contributing to the community and sharing what we learn
-we send our developers (yes, even contractors) to conferences – e.g. this year we paid (airfare, accommodations, conference passes, etc) for them to go to both 360 Flex conferences (east and west coast), Adobe MAX, and 360iDev
-very informal, close-knit team environment

Posted in RIA | Comments Off

Why Adobe should develop Flash Player for Jailbroken iOS devices

It seems a pretty consistent trend that Apple incorporates features developed on/for jailbroken devices into future versions of iOS. It’s almost as if they actually monitor the jailbreaking scene and say, ‘hm, folks seem to want these features enough to jailbreak their devices for it’ and voila, next thing you know, they are announcing, for example, folders on iOS. The fact is our iPad is extremely more useful with Frash running on it, even though Frash supports only a tiny fraction of the flash player functionality…mostly it seems, only stuff that is timeline based although we have seen some limited video functionality.

Imagine if Adobe officially developed and supported Flash player on iOS. Sure, it wouldn’t be on the vast majority of iOS devices or in common use as it is on the desktop browser. Then again, I think you would see a much larger segment of the population jailbreaking their devices specifically just to have the benefit of Flash player.

We saw that with Epic’s demo of Unreal Engine on iOS, Apple suddenly relaxed the third party development tool restrictions for developing on iOS. Did Epic wait for Apple to give the green light before putting serious development effort in developing Unreal apps for iOS? How about Open Plug – did they wait on Apple’s approval to move full speed ahead with developing iOS features in ELIPS Studio? I hope Adobe is at least secretly moving full speed ahead with developing a Flash player for iOS regardless of Apple’s stance on the matter…but I would hope they would make versions of such a player available to the community…

In the meanwhile I guess we have to make do with the Frash port of Flash on iOS

Posted in Adobe, Apple, Flash, Flash Lite, iPad, iPhone, RIA | 1 Comment

review: TwelveSouth BookArc for iPad

I just received and started using TwelveSouth’s stand for the iPad, BookArc. In short, it looks really cool, which is an obvious selling point. In use though, at first I was a bit dismayed, as when the iPad sits up straight in the stand, it’s at a pretty awkward angle if you’re sitting at a desktop and trying to view the screen. It does have an alternate angle, though, but it took quite a bit of figgling with the stand to figure out how to get the iPad to sit in it properly. The slot for the iPad is a very soft rubber, so it’s definitely gentle on the iPad, however when you touch the screen (as per normal interactions with the device) the iPad shakes quite a bit…just a bit annoying. I had to make sure I touched the screen gently to minimize the shake. With a bluetooth keyboard and mouse (see this hack for getting the mouse to work) though this setup seems to have quite a lot of possibilities…
Oh, and if you just recently updated to iTunes 9.2 and found out that if you want to jailbreak your iPad you’re outta luck…here’s how to downgrade iTunes to a previous version.

Posted in iPad, mobile | Comments Off

An Open Letter to Oakley.com

Dear Oakley.com,

I spent many hours in the mall in Columbia, Maryland, this weekend, trying to buy a pair of prescription eyeglasses. I started with the Oakley store, where I picked out the frames I wanted. I had actually decided from your web site which frames I wanted, but the Oakley store didn’t carry those frames in the color I wanted – they said their selection was very limited because they didn’t sell the prescription frames very well. I soon found out why.

Once I decided on a pair they did have that I liked, they told me that I would have to take the frames to an authorized Oakley dealer, of which there were three in that mall. They said they were no longer allowed to send the frames in themselves to get the prescription filled (I had my prescription with me) because they had gotten in trouble for that, apparently something to do with not having a doctor in their store.

So then I went to Pearle Vision. At Pearle Vision, they wanted to sell me their lenses instead of sending the frames in to Oakley. When I insisted on Oakley lenses, they made a show of calling Oakley (I have my doubts as to whether or not they actually spoke with Oakley on the phone, for the reasons I will illustrate shortly), and then they informed me that for the frames I had chosen, my prescription index was too high. The sales person claimed that Oakley told him that the frames only supported up to a total power of 5. They said they could put their own lenses in, but Oakley would not put in lenses at that prescription.

So then I went back to the Oakley store and told them what happened at Pearle Vision. The gentleman who had helped me looked up the frames in your catalog and found that Oakley supported up to a total power of 7 on those frames, not 5 as Pearle Vision claimed. They suggested that I try the other two vendors in the mall, Lens Crafters and Sterling Optical. They suggested I go to Lens Crafters first, because ‘sterling optical had lost their trust’. When I asked why that was the case, they told me that Sterling Optical had ripped off many of their customers who ordered Oakley lenses, substituting their own lenses instead and reselling the Oakley lenses for additional profit.

So then I went to Lenscrafters, where I faced a similar situation as I had at Pearle Vision. Only this time the sales representative wouldn’t even call Oakley – he said they would not send the frames to Oakley because Oakley would not fulfill my prescription. He was eager to sell me Lenscrafters lenses in my Oakley frames, however. He quoted me a price which turned out to be much higher than the price if I had gotten genuine Oakley lenses.

Finally I went to Sterling Optical. I told the sales lady what had happened to me at the other stores and I asked to her to check her Oakley catalog and call Oakley to confirm whether they would fulfill my prescription. She did that and she said that Oakley would indeed fulfill my prescription. She calculated the total power of my prescription to be sure – and indeed it was under 7, which is the limit Oakley set for those frames. She then proceeded to write up my order, which came out to $408 JUST FOR THE LENSES. Now, luckily I had done a little homework – I did notice on your website that you advertise a single online retailer. Through that retailer (Sports Vision Bend), comparable Oakley lenses are $189 plus $60 for the anti-reflective coating. So, Sterling Optical wasn’t going to rip me off by keeping my Oakley lenses for themselves (the sales lady made a point of telling me that I could tell the lenses were genuine because of the Oakley logo on the lens), but instead they were going to rip me off by charging DOUBLE the price of my Oakley lenses.

Why didn’t I just buy my glasses from the online retailer to start with? Because they only offer ONE of your vast selection of half-rim frames. That’s right – after I spent the time browsing through your great selection of frames online, I found that NOBODY actually sells them. I can’t order them direct from Oakley, I can’t buy them from the Oakley store in the mall, and even if I do find an alternate frame I’m happy with in the Oakley store, I then have to go to another retailer who is supposed to be a partner with Oakley, only to find that they really just want to sell me their own lenses (which void the Oakley warranty of-course, cost more, and don’t have any of the great technological benefits of genuine Oakley lenses), to the point that they will lie and cheat about it. I honestly felt like I was shopping for a used car rather than for glasses – such a dirty feeling. The sales person at the Oakley store seemed to think what these other stores was doing was illegal and in violation of their agreements with Oakley.

Do you see something terribly wrong here? What’s the point of having a great selection of frames on your web site, if they aren’t actually available for purchase, either online or in a retail store anywhere? What’s the point of having ‘authorized dealers’ if those dealers don’t actually want to sell your product, and just want to use your name to pull a bait and switch scheme? You really ought to allow your customers to send you their eye prescriptions directly, and order directly from your web site. You certainly won’t be hurting your partnerships with these so-called dealers since they aren’t selling your lenses, anyway.

In the end, I bought my Oakley frames and lenses from the online retailer – but I REALLY wish they would bother to carry more of a selection of your frames. Furthermore, Sports Vision Bend seems like a really small operation – I mean come one, they don’t even have their own domain name!

UPDATE: Sports Vision Bend actually contacted me, they were extremely courteous and professional, and it turns out they do indeed have a much wider selection of lenses than I originally thought – they just could use some uxd / nav improvements on their web site. Here’s a link to their full Oakley selection. Furthermore, they offered to check if the Oakley lab had a specific color they didn’t list on their site, but was listed on Oakley’s site.

Posted in business, retail, RIA | Comments Off

How not to frag your Flex Team (or ‘How to prevent . actionScriptProperties and other files from getting checked into SVN)

The situation: you wake up one morning and update your flash builder project, only to get an error message saying there is a conflict in .actionScriptProperties. Images of the rap video Who Broke the Build suddenly rise up out of you memory…before you throw that keyboard through that nice 30″ Cinema display, take a deep breath and read on. It’s not as bad as you think. In fact, you could have prevented this from happening in the first place, but now that it’s happened, you can fix it so it doesn’t happen again.

Assumptions / Background:
-you’re using Subversion (SVN) for version control
-you’re using Flash Builder (same applies for Flex Builder, but this tutorial is specific to Flash Builder) with the Subclipse plugin

Sometimes you want to tell svn not to update or commit certain files in your local project, such as .project, so you don’t have to remember not to check them in when you do a check-in at root level. You could try telling your team to just not check those files in, but not only is that a pain to remember to do, but most likely in the end they will wind up getting checked in, anyway. The common solution to this is to use svn:ignore, which tells svn to ignore those files and not check them in. To get to that option normally would be easy – just right-click on the file or directory in Flash Builder and choose Team->Add to svn:ignore. However, most likely if you are trying to ignore files or directories that start with a dot ‘.’ then you aren’t seeing them in Flash Builder at all, are you? The dot is the naming syntax for hidden files in unix/linux, and Flash Builder / Eclipse respects this. OK, so to see the files within Flash Builder, first of all, switch from the Package Explorer (new to Flash Builder) to the Navigator (more like what we were used to in Flex 3 and prior):
getting to the navigator window in Flash Builderselecting the navigator window in Flash BuilderNavigate to Window->Other Views and then select the Navigator. Now you should see your project by the file structure rather than package structure. Next, select the drop down menu from within the Navigator and choose Filters, and uncheck whatever types of files you want to see.Filters option in the Navigatorviewing hidden files in the navigator

OK, so now you see the file you want to ignore…but if the file was already added to svn, that option to svn:ignore it is grayed out.

When a file has been added to svn already, the option to ignore it is disabled


Now what? This part is a little more tricky (I found the solution for this next part here):

1. Delete the file from the repository (make a backup first!)
2. Recreate it in Eclipse
3. Set svn:ignore on it via Team->Add to svn:ignore

Hopefully now you’re good to go, and your Flex team is still alive and breathing! ;)

Posted in Adobe, Flash, Flex 4, RIA | 3 Comments

Capital Flash Camp 2010 : A brief recap

I attended Flash Camp in DC today and though I would share my initial impressions, given that we were at 360 Flex not too long ago and a lot of attention is being given to the upcoming Flash & the City conference coming up in NYC soon. First off, I will admit my motivations for attending were (a) because it was local to us and (b) because our User Experience Designer, @adnaanahmad was presenting on Catalyst. If reason (a) were the only reason, I might have gotten lazy and not gone at all, but reason (b) was enough to mandate my attendance. Anyway, three main areas caught my attention regarding Capital Flash Camp: the speakers/presentations, the conference / organization itself, and the food. You might think that the first area, the speakers / presentations, should be the sole focus, but I guess, the same way you notice bad design because it hinders you, but you don’t notice good design because it’s doing its job, also these satellite issues contribute or detract from an event such as this.

Conference / Organization
What, no name tag?
I guess this is an area where stuff I had been taking for granted, from my experiences at MAX, and now 360 Flex, kind of stood out. We might tend to think of name tags as a bother, but part of the reason we attend conferences is to network. There seemed to have been no thought given to the networking aspect at all at Capital Flash Camp. Don’t get me wrong, we don’t need fancy lanyards and stuff – a simple sticker you write your own name on would have been sufficient. Then again, I guess that forces folks to try and open their mouths and actually ask each others names…not such a bad thing, eh? So, was this an oversight or actually a clever, well designed ploy to encourage folks to get out of the closet and actually develop social skills? Either way, it did get my attention.

There was also no swag…not at the registration desk, anyway…kind of a disappointment. I don’t count Adobe pens and stickers left over from 360 Flex as swag, sorry…aren’t conference shirts a defacto standard?

Attendance wise, I was actually pretty disappointed. The conference was held in a relatively small area, with all the talks being held in a single, small auditorium with a huge curved screen. However, the number of attendees might have made the place look vast. There were maybe only fifty attendees in the beginning, and for some reason as the conference progressed that number continuously dwindled. I left early myself, with two sessions and the giveaways still pending, but at that time there might have only been twenty or so folks left.

Speakers / Presentations

I walked into the conference in the middle of @jefftapper ‘s presentation Flex 4 for Flex 3 Developers. Jeff’s presentation was excellent, and I definitely plan to go download his lecture notes since we are at the beginnings of a flex 3 -> flex 4 migration, ourselves. Of particular interest is the list of mx components that were not ported to the spark space at all, such as DataGrid and ViewStack. One of the first questions I posed on twitter as we started migrating our code to the spark space was, ‘are we supposed to mix mx and spark components by design?’ I got a bunch of tweets in response referring either to custom components folks had built in the spark space or on how to mix mx and spark components. Jeff’s response was that he felt that Adobe hadn’t done this themselves yet due to time constraints. Ah…

Next up was @queencodemonkey on Greenthreading in Flex. I already saw her presentation at 360 Flex, but as I told her, it was one of the best presentations I had attended, with regards to stuff I was able to take back to my team and say, ‘hey, this is something we should look into with regards to what we’re currently doing’. So it was enjoyable to see it again, and a good review of the concepts and applications. I also made a note to go and read an article she referred to by @ jesterxl on loading massive amounts of data in the Flash player, and they both were kind enough to tweet the link to the article.

Next was The Art of Storytelling by @christiansaylor. It was a nice change of pace from the technical presentations, and indeed, he is a great story teller himself. I kept thinking that his presentation style was highly reminiscent of Steve Jobs, and when one of his slides was a huge photo of The Evil One (as one audience member called out, lol) it pretty much cinched it in my mind that was a source of influence for him. In a good way…

Christian also convinced me to take a closer look at Audi…

Towards the middle to end of the presentation, I kind of felt like it was tending towards a sales plug for Universal mind, but then again, they sponsored and organized the event, half the speakers were from their company – so what could you expect? In the least, at least this presentation was pertinent and well done, unlike the eBay sponsor presentation at 360 Flex, which had me wondering if anyone, really, ANYONE in the entire audience cared an iota about what the speaker had to say or if what he spoke on had anything at all to do with real business problems faced by anyone in the audience.

next was lunch…

The Food
What can I say, without getting too insulting? Meh. Not a highlight of the conference. At 360 Flex, they had good food, but it would run out before you could actually get any. For some reason, I found that more appealing than food you got but didn’t find appetizing.

More Great Speakers
@carlsmith spoke on the importance of listening to your audience in It’s a Matter of Trust. Frankly this was by far the most entertaining session, hands down. The volume and amount of laughter in the audience was a clear indication of that. He brought up twitter a lot in examples of customers complaining about the service of companies, and the successes and failures of companies leveraging twitter to satisfy customers. The bottom line of his presentation: treat your audience as people, not as statistics.

The last session I attended before ditching was Introduction to Flash Catalyst by @adnaanahmad. Adnaan’s presentation was great, especially considering it was his first conference presentation, ever. I think the audience was hungry for more on his demo side; the background info etc. is all good and well, but that’s stuff folks can read about later or have already done so, the demo is what really engaged us. He also made a pretty good case considering there was only one designer left in the audience at that point and the rest were developers.

You can find a small slideshow of the photos I took at the conference here.

Posted in ActionScript, Adobe, Design, Flash, Flash Catalyst, Flex, Flex 3 -> Flex 4 Migration, Flex 4, Illustrator, Photoshop, RIA, Software Architecture, UXD, Wireframing | 3 Comments

in review: ‘Crush It!’ by @garyvee

If you’re already on top of social media, using LinkedIn, twitter, Flickr, blogging, etc., and if you already have a terrific work ethic and do what you love, this book has absolutely nothing to offer you. Well, Gary is an engaging speaker, so maybe it will keep you awake during rush hour if you get the audio book, but I’m sure you could spend your money on something more engaging for the price. Gary is a bit rough around the edges, I can’t see value in this as a print book as compared to the audio book which is read by him, and his strength is clearly as a speaker and not as a writer. I would recommend this book to those of my friends who I know don’t quite understand the social media scene or who might need a little motivation. If you watch some of the free videos online of Gary speaking you will get a pretty good idea what this book is about and what it has to offer – its not much different from his keynote speeches.

Posted in RIA | 2 Comments

Flex 3 Word Wrapping Does Work Afterall

Turns out that word wrapping in Flex 3 datagrids does work after all.  After adding wordWrap=”true” to Flex 3 datagrid columns to no effect and much fustration I came across this solution/explanation by Bruce Phillips.  In short, you need to add the parameter variableRowHeight=”true” as a property of your Datagrid.  For a more detailed explanition be sure to read the full article on Bruce’s blog.

Posted in Flex | Tagged | Comments Off

Two-way Data Binding in Flex 4

In Flex 3 we created a data binding expression using curly braces, like so:

<TextInput label="textInput1" />
<TextInput label="textInput2" text="{textInput1.text}" />

In Flex 3 if you wanted to make the binding two-way, you had to make a second binding expression. However, in Flex 4 you can just add an @ sign to the binding expression to make it two-way, like this:

<s:TextInput label="textInput1" />
<s:TextInput label="textInput2" text="@{textInput1.text}" />

Posted in Adobe, Flex, Flex 3 -> Flex 4 Migration, Flex 4 | Tagged , | Comments Off