The Fan, Comcast’s Flex based video player: SHIPPED !

WooHoo !!!!
The Fan, Comcast Interactive Media’s flagship video application, which I worked on as main architect and lead developer, was deployed to production this week. The Fan is currently one of the top 10 online video destinations and the new version adds a LOT of cool features to the application. I have already talked about developing the Browse view using the Flex out of the box components and then later writing a component set for the circular view, which HAS to be the most interesting UI for a Flex application ;).

Fan 3 vs Fan 4 Classic view

fan4_circle

fan4_circle

Fan 3 vs Fan 4 Square view

Fan 3 Square

CIM Fan 4

If you are a Comcast subscriber, go to the comcast.net site and watch any video from the huge number of links we have peppered across the portal. The link to the preview version of the fan is still alive from the cimlabs site, so check it out soon before that goes away if you havent already.

As the fan continues to evolve and we get ready to launch another bunch of Flex modules, we are still looking around for Flash/Flex developers. So ping me if you are interested at arpit_mathur [at] comcast.net

The much awaited notes from Flex training day 3

Earlier I had asked if anyone had any Flex questions I could ask Jeff Tapper when he came by to train the group, and a few people did. Unfortunately, the last day I had a major meeting maelstrom (try saying that three times fast) and so I didnt get to work on any of the cool stuff (but the rest of the team did and that was the point for the most part anyway). But I did ask a couple of questions that were posted. I do apologize for taking a week for putting these up but its been a crazy week.

Paul Rangel asked:

I have a list of questions but I’ll start with the one that “gets my goat” the most these days. It’s with the preloader. We’ve done some custom preloaders using the Flash CS3 integration kit and it’s awesome. We modified Ted Patricks class for overriding the default preloader and added an additional phase to the loading process to load a configuration file for our applications while the app is doing it’s instantiation. All is well until we try to save this data to be used in the app!! There’s no way to save it in a variable that is still accessible once the app. has instantiated. Or is there?

To sum it up.
Is there a way to load an XML config file while the Flex framework is loading and have that available in the app?

Our solution:
Save it in a shared object ( write it to the disk) and call it up once the app has creation completeded : ) . This solution is fine but I figure there has to be another way since we use this design pattern in 90% of our projects and I would like to make the most of the inital load since the user is waiting anyway.

So turns out the entire group has never written a custom preloader before (oh the shame!), but the idea of not being able to use the loaded data baffles the mind. Probable solution: Use a singleton class with no strings to the Flex framework to load the data and reference it in the application when the application is initialized. Go completely native and use the URLLoader and the URLRequest objects if you have to (I am not sure if HTTPService has any dependencies on the SystemManager being ready). And do let us know how that works out. If anyone else has seen the same issue or has a solution, please drop me/us a comment as well.

SmackDaddy asked :

What is the best way to implement a global exception handler in my Flex apps. Every other language I use has one, and I *really* need to know when errors are happening, because my users are not telling me all the time.

So we wasnt sure about this. If the idea was to catch an error at ANY time, then wrapping your app in an uber-try/catch block was a possibility (ugh), although I dont think that would work for async httpService calls will it? However I dont think there is any official way to handle global exceptions.

I would like to see an example of the best, proper, yet simple way to build lazy trees. I’ve never seen a good, clean, easy to understand example in Flex.

Again, none of us have an answer to this since we hadnt ever done it. But I can imagine a solution where you load node data only when required and since the performance of such an app would suck, you could try an aggressive strategy where you load one subsequent node worth of data (other than the ones open) and when a user opens a node, you fetch another node down as well, the idea being you keep fetching data for nodes that the user may open next. The retrieved data can be then spliced into the dataProvider of the tree. I’ll try to dig up a link that also talked about data refresh without closing the whole tree (which seems to be Flex’s way of handling a change in the dataProvider)

I guess most of the answers here are “umm…., we could try …”. If any readers have the answers then please feel free to comment.

-cheers

Notes from day 1 and 1.5:

Like I had mentioned in my earlier post, the Flex team at Comcast Interactive Media in undergoing a training for three days on all things Flex with Jeff Tapper (of the Adobe Flex Training from the Source book fame). I have been in and out for the most part but the team seems to have absorbed a lot.

Here is a quick list of things that I learnt:

Using [style] metatags to create accessable styles:
By just putting the [Style] tag, you can make the styles available to you (well, more visibly anyway). You can also add the inherit=yes value in the style definition and the style will get picked up from the parent’s style values. Something a lot more interesting that I was looking for is the StyleManager.registerParentSizeInvalidatingStyle method that forces the parent to measure itself when a style value could potentially grow the component to a larger value needing the parent to do the same.

Using BindingUtils and the ability to bind to events:

I have never done the latter (weird I know). However it seems if you but the bindable metatag with the event name on top of a function, that function is called whenever that event is fired. Since we didnt specify a target (source) of the event, does this event get fired anytime anyone fires that event? I am still not sure.

Using namespaced XML:
If an XML file has namespaced nodes, you cant access those nodes until you include that namespace in the XML definition. To do that you would create a namespace variable and then use that to reference the namespaced nodes:

For example

x:XML = …
var rdf:Namespace = new Namespace(“http://rdf……”)
var dirvalue = xml.rdf::Directories
Note the use of the ::

Using ASyncToken:
This is returned from the HttpService call. It acts as a token for the call and can be used to attach fault and result functions to. I have never used it. Interestingly the Flex source code doesnt including the rpc package so I have no idea how its created.

Event Lifecycle:
We saw the difference between the event.target and the event.currentTarget. Also what was really useful was figuring out the event.stopPropagation and the event.stopImmediatePropagation. The former stops the event from going anywhere up the Displaylist but if you have two event listeners added to the same displayobject, both will get the event if you only use stopPropagation, but if you use stopImmediatePropagation, you can intercept the event preventing it from going any further even to other listeners on the same node in the DL. This property can get more useful when you use event priorities to register listeners.

Modules
Ran through a simple example of using modules especially using the -link-report and the -exclude-externs compiler directives to make sure the modules only compile whats needed. Apparently this gets easier in Flex 3.

These are just my notes, since most of the other stuff we talked about I already know ;). More stuff here tomorrow.

Do you have any questions on Flex? Any questions at all?

Continuing the effort to making Comcast Interactive Media a Flex center of excellence, next week the team here is going to be trained by Jeff Tapper, one of the biggest names in the Flex community. Most Flex developers may know him from his book, Adobe Flex 2, Training from the source. Since the team here has been working with Flex for a while, we are not going to have a structured learning class but rather a free 3 day long QA + coding sessions.

I do have a list of questions I want to ask him, but they arent that many. So if you guys have any questions, drop me a comment and I will try my best to bring them up, since a lot of the answers will be beneficial to all. At the end of each day I will put up the day’s conversations up online for the whole www :).

And if you want to be part of the Flex developer team at Comcast Interactive Media, drop me an email at mathur.arpit [at] gmail dot com.

Fan4 Beta: Thinking Flex out of the box !

Last week we updated the build on link to the Fan 4, Comcast Interactive Media’s flagship video product. The new build includes the ability to switch your preferred video viewing experience between a “traditional video page” experience, the unique circular video playback experience that the Fan has traditionally been associated with, and also a fullscreen view. As we continue to work towards the final release of the application, I thought I should take a few moments and talk about the experience of building a Flex app like no other :).

I had already talked about how and why we built the alpha version with Flex in a previous post. I was pretty surprised by how many people picked it up. As of right now, the mode is still featured on scalenine.com, a site archiving some of the best skinned flex applications out there. However, while the page view of the alpha release was very well skinned, the basic interactions on the application such as drag and drop playlist controls and data bound UI components were still fairly out-of-the-box Flex. The circular view of the Fan is however anything but traditional and so we ended up writing a lot of custom components to get the look and feel of the application right.

fan4_circle

A deeper look into the circular view:
Gabo has a pretty nice video capture of the Fan 3 application’s interaction model on his site. The goal of the Fan 4 circular view was to keep most of the functionality the same. On the circular view, the traditional list of queued videos is replaced by an arc of blades. The drag and drop metaphor remains, but users can also delete the videos from the queue by simply dragging the blade far enough away from the circle. We also removed some of the controls that seemed to clutter the interface. The idea is that the circular fan is a fun UI with the ability to switch to the page view to browse more content.

Some thoughts on the experience:
As you can imagine, implementing this view was a lot more difficult than just skinning the Flex controls. However by the time we were done with the square view, we seemed to have Flex kinda figured out ;). One big thing that I feel Flex taught me was ‘thinking in terms of components’. In the end I was pretty happy with the implementation. The circle view is basically 3 components (controls):
1) A CircularNav component that can takes an ArrayCollection of Video Value Objects as a dataProvider, creates ‘Fan Blades’ representing them and manages scrolling through them.
2) A CircularBackground component that basically holds the video player, and
3) An ArcList component that takes takes an Array of links as the dataProvider and basically lays them out in a list that scrolls along the circular path.

A little more about the ArcList:

arclistNow that we seem to understand the spirit of the Flex framework, we try to implement our custom controls with it in mind. For example, the ArcList control behaves very much like the Flex list class. Besides the ability to pick any radius along which the list should scroll, we can add different renderers to the ArcList and style the colors in CSS.

Know thy measuring:

We didnt pay much attention to overriding the measure function and things were fine for a while. However when we tried to use the horizontalCenter and verticalCenter styles, they wouldnt work right till measure was correctly implemented.

The need of another framework:
As we work now to finish the application, getting this baby to hit primetime in front of the millions of users, we are feeling some pain arising from the complexity of the application. Because the fan has a number of components interacting with each other and has hooks to allow us to add new views to the application (sphere? octagon? triangle? ;)), we do once in a while find a bug as the application goes from one view to another. Something I found fairly recently (thanks to the Philadelphia Area Flex User Group) is Cairngorm. For the uninitiated, Cairngorm is a framework that enforces the MVC paradigm on your application. The framework is owned by Adobe now I guess (I think they bought the company that originally owned it, but there are a lot less people using Cairngorm than Flex and online resources arent as easily available). While adopting Cairngorm a couple of months back wouldn’t have been a great idea, using an MVC framework that we didnt know on top of the Flex UI framework that we just barely knew, I think we may now start exploring it, maybe for a Fan 4.5 release ?. Anyway, its something we are going to look into.

Some requests for Flex 3 / 4.
Since Flex 3 is in beta, I guess all I can do is make some requests for Flex 4. While Flex Builder seems to be approaching maturity as a development tool with refactoring support and the profiler, there needs to be some effort on team support on Flex applications. For example, we were having issues with OS path separators in build paths since some team members were on PCs and others on Macs. There also arent any articles I have been able to find on best practices when developing in a team (a MAX session anyone?)

Anyway, do take a look at the application at http://preview.comcast.net/fan4 and send me a note if you find any bugs or think some features may need improvement.

Cheers.

DiggGraphr Desktop ported to AIR

A quick update for anyone using or interested in DiggGraphr Desktop. I ported the application to AIR today (it was a fairly painless operation requiring changes to just the application descriptor XML file and the parent tag of the application). So go ahead and get the latest build from here. For the uninitiated, the DiggGraphr Desktop application uses the treemap algorithm (with the theme from the newsmap application by marumushi) to render out Digg stories in treemaps. Customization even include auto refresh and custom pages. Details can be found on the application page here.

A tale of AS2 AS3 Integration: Go CSS !

I have seen a couple of posts recently from people looking for some information on integrating AS2 and AS3 code. I recently worked on a project that I ended up spending quite a few hours trying to get some things to work right so I figured I should post about it. Hopefully someone will find it useful.
So I wrote a Flex application that I was able to knock out fairly quickly. The core framework really made a lot of the grunt work disappear and I was pretty pleased with what I had. It was only when I was done with the application itself was I informed that the application was supposed to be loaded in an AS2 swf. Ah well, I could always loadmovie it.
Wrong.
AS2 swfs cannot loadmovie AS3 swfs. I guess the swf headers dont get recognized by the Flash Player and the AVM2 doesnt startup. So we had to find a workaround to that. I was hoping Javascript popups would work but that was unacceptable user experience. So we went back to the drawing board. The other option seemed loading the existing AS2 base swf using an AS3 basic loader as the root. It worked well for a few initial scenarios but soon hit a wall since there were _root references all over some of the AS2 code and the root loader killed all that functionality (For those who still do so, please STOP using _root in your code !!!).
Just when I was ready to quit and about to just port the whole app to AS2, I tried going completely out of the flash player to get my application to show up on top of the base swf. Go html positioning. I ended up writing both the swfs into 2 separate divs using swfobject and then absolutely positioning the base swf and relatively positioning the container with the Flex application on top of it.

The css styles looked like this:
[css]
#div1{
position: absolute;
margin:0px;

width:100%;
height:100%;
}

#div2{
width:500px;
height:360px;
position: relative;
margin-left: auto;
margin-right:auto;

}
[/css]

Works pretty well :).

Glorified Greasemonkey-esqe applications with AIR

For the last couple of days I have been monkeying around with the HTML control in AIR. One aspect that fascinated me was the ability of AIR to execute arbitrary javascripts to manipulate the DOM of the loaded document. So I wrote this proof of concept application which I LOVE. I use Yahoo news for all my news needs (well that and BBC), but yahoo is too branded and has way too many ads for me. So I wrote this application that lets me browse yahoo news but strips the branding and the ads.

cruncher_air

The left column of the application is fed via yahoo rss feeds. When the list item is clicked, the html control loads the link specified and then executes some dom scripts that looks for certain divs and removes them. I also had to change the content’s css style to allow it to float left.

Cool. My news browsing experience has just gotten a lot better 🙂

Be careful what you loadmovie…

After being involved with AS3 and Flex for so long, I think I am now at a point where I have a really good understanding of the Flex framework. So when I was asked to build this online app, I immediately started it with Flex and before long had most of it working. However, the application was supposed to be a subcomponent of a larger AS2 project and was supposed to be loadmovie-ed. I didn’t realize till too late that AS2 swfs actually cannot loadmovie AS3 swfs (well Flex for sure, not sure about AS3 but doubt that too). This definitely left me feeling very ‘d-uh’. We ended up working around this by creating an AS3 base swf that loads the AS2 swf and then when the sub-app was supposed to be loaded, the AS2 swf told the base movie to do so via LocalConnection. This is definitely a hack but I couldn’t think of any other way to get this to work.

If anyone is aware of this or has successfully managed to load an as3 swf into an as2 swf via loadmovie, do drop me a comment. For others, be careful what you loadmovie ;).

It aint about the tech…

I usually keep personal observations on my blog to a minimum, keeping it more about the code and apps. But off late I have been feeling this a lot and so I feel I must speak at least once if only for cathartic release ;).

There has been a lot of new activity in the UI world: Apollo, Silverlight, JavaFX, WPF and now Ted Patrick’s sneak peeks on the new features of Flex 3, and a lot of people have very strong sentiments about it. However it seems like we have all set camps around technologies rather than what they mean for the end user.

Silverlight was the perfect example of course. While blogs on mxna screamed how it was utter crap, people I know who attended the Microsoft MIX conference proclaimed it to be the undoubted Flash killer. As a UI developer who moved from Java to Flash to Flex to now-eyeing-the-3D-capabilities-of-WPF, I couldnt care less about what I write my code in. If there is something in Silverlight that I cant do in Flash (and my target audience has the plugin), I will code in it.

But the Silverlight conversation is over so lets continue…

The latest thing is the Flex 3 sneak peeks. I have read quite a few blogs about the lack of any earth-shattering new component in the framework. I am not surprised. Now that I have been with Flex for about a year, I am truly loving it. I dont care about the List, Datagrid or the Tree component, heck I could them all easily in Flash. Flex gave me a framework to work within. When I work with another developer or look through a component’s source code, I KNOW what I am dealing with: I know the measure function is where the measurement is happening, and updateDisplaylist is where the component is drawing itself out, etc. Now its up to ME to code my cool app. I will write a component to suit my application’s need rather than look at the new component set and try to fit those into an application. Adobe cannot write a component set for every app out there. Flex 3 gives me exactly what I want: A better way to write code (Refactoting, Code assist, etc), a way to make sure I am not killing a user’s computer (with the profiler stuff) and a better way to deploy it (using the flash player’s caching mechanism): after that I almost want it to leave me alone and let me build my app to work the way I want it to.

I dont want to sound harsh. Heck I would love to have some cool components that I may use once in a while, but its not something I expect to get from the SDK. For that I look at the broader community out there.

Lets make cool things….