Alain Hufkens {Rich Interactive Applications Developer}

31Mar/091

Be careful with transparent AIR apps

air_appiconAt my company I developed an Adobe AIR application created in Flex for internal use. The application uses custom chrome because it has a specific designed interface. At the time we also decided to enable the transparency. To achieve this, you only need to change some settings in the AIR configuration file. This file is located in the root of your Flex project and ends with "-app.xml". The first setting turns off the default OS specific chrome and the second one make the application transparent.

<systemChrome>none</systemChrome>
<transparent>true</transparent>

This is all very cool, and it worked out great for me. Sure, the application used a bit more CPU then expected, but that's a known issue for AIR applications. But some of my colleagues complained that their CPU went through the roof (more than 50% while doing nothing) and the application became unstable. Wouter Martens (currently doing his internship) stumbled upon this blog post because he also had the CPU issue on his machine. It turns out that the problem is depended on hardware, and that explains why some people have issues and others don't. We tested the same application without the transparency and the CPU issue was gone.

Luckily it turns out that we don't really need the transparency, and that we can easily change the design without a lot of impact. Changing the transparent setting in the xml file to "false" did the trick.

<systemChrome>none</systemChrome>
<transparent>false</transparent>

This demonstrates that it's not that trivial to create a cross-platform run-time, that also behaves consistent over all platforms and all hardware.

Filed under: air, flex 1 Comment
18Mar/094

What’s new in Silverlight 3

cusersdavcrowdocumentsbloggingmix09logoToday was the day of the MIX conference by Microsoft in Las Vegas. After the Techdays last week I was a bit disappointed in the Silverlight presentations. But on MIX they announced a lot of new features that will end up in the next version of Silverlight. I have found this list on a couple of blogs from Microsoft employees. Some of the stuff we can already do in Flash but other features might become interesting in the future.

  • Video/Audio. Silverlight 3 now also supports the H.264 video format in addition to VC-1. It also supports the AAC audio format; both this and H.264 are implemented within the MP4 container format (i.e. .MP4 and .M4A files).
  • GPU Acceleration. This is an opt-in feature that is available within the Silverlight 3 runtime, both in-browser and out-of-browser.You can add a parameter EnableGPUAcceleration, and set it to true, to enable final surface draw GPU acceleration. This could be something that can out performe the Flash player.
  • 3D Support. Silverlight 3 includes perspective 3D, which gives you much of the benefit of 3D without the “productivity penalty” of having to write it from scratch.
  • Animation Easing. There’s now a series of easing functions.
  • Custom Dialogs. We now have SaveFileDialog support in Silverlight 3. For security reasons (because Silverlight runs in the sandbox), we don’t return a path to the developer.
  • Effects. Effects (introduced in Silverlight 3) provide a low-level way to impact visual behavior (rather than functional behavior). We provide drop shadow and blur effects out of the box, but you can also create your own.Custom effects are implemented as HLSL shaders – these can be compiled into byte code using a DirectX SDK utility, which Silverlight 3 then consumes. Something similar to Pixelbender?
  • Pixel and Media APIs. You can now read/write pixels from a bitmap. There are two ways this functionality is exposed: either as an in-memory bitmap or by saving a visual to a bitmap. Also supported are raw audio/video APIs that enable dynamic sound generation, custom video codecs or indeed alpha video channels.
  • Local Messaging. One common challenge is messaging across multiple Silverlight plug-ins. In Silverlight 3, we now support “named pipes”-style messaging across not just objects on the same page, but even multiple Silverlight instances across multiple browsers.
  • Out of Browser. A user can start a Silverlight out-of-browser “application” either by right-clicking on the Silverlight content, or by clicking on a custom button within the application itself. So now we can have Silverlight applications running on the Mac that can run offline.
  • Tooling. The Silverlight 3 tools will introduce a new compression algorithm that will reduce the size of XAP files by 10-30%. So that's great news because Silverlight xap file tend to grow large very quick as they use extra dll files.
  • eclipse4SL: the Mac version of eclipse4SL is available for download, so now you can develop Silverlight applications on the Mac.

UPDATE: Read more about these features in detail in Tim Heuer's blog post: A guide to Silverlight 3 new features.

It's a nice feature list, but most of this stuff can also be achieved using the Adobe Flash Platform. But given the fact that the .NET core runtime is a powerfull development platform and the vast amount of developers, we should see some cool stuff coming in the future. The only feature that I haven't read anything about is Silverlight for Mobile. Maybe I missed it, or maybe it is something for later on.

Filed under: silverlight 4 Comments
17Mar/090

Apple iPhone OS 3.0 announced

iphone-os-preview-sdk20090317Today Apple announced the new version of the iPhone Operation System. The whole community was really looking forward to the new features, and Twitter was overloaded with #iphone tweets. Off course for us Flash Platform developers it would be interesting to know if the Flash Player would end up on the iPhone at last.

Well no Flash on the iPhone but a lot of other cool stuff was announced:

  • In-App Purchasing: Allows developers to sell additional content from within applications. Highlighted uses include magazine subscriptions, eBooks, additional levels and items for games.
  • Peer-to-Peer Connectivity: Find other devices running the app via Bonjour over Wi-Fi of Bluetooth. Good for gaming, but also other applications for sharing data.
  • Third-Party Accessory Apps: Allowing accessory manufacturers to create applications to interface with their hardware accessories.
  • Push Notifications: Rather than using background processes that hamper battery life, utilize third-party server to push badge, text, and audio alerts from applications.
  • Turn by Turn: Apple will allow developers to use CoreLocation for turn-by-turn GPS directions. Finally TomTom on the iPhone?
  • Cut, Copy and Paste: Available across all apps. Shake to undo or redo.
  • Landscape keyboard: Available in all key applications, including Mail.
  • MMS: Picture messaging now available.
  • Voice Memos: Record notes, lectures, interviews, etc.
  • Spotlight Search: Available across all applications. Systemwide search available from main home screen by flicking to the left.
  • A2DP Bluetooth: Support for stereo bluetooth headsets.

More information about the new iPhone OS can be found on this preview page on the Apple site.

Filed under: iphone No Comments
17Mar/090

Flex HTTPService and Basic Authentication

For an internal project I created an Adobe AIR application that connects to the Basecamp API. We have been using the application since the launch of Adobe AIR. Back then I had a problem connecting to the API using the HTTPService, because the combination of Basic Authentication and the https protocol was not supported. After several unsuccessful experiments I decided to go for an approach that uses a PHP Proxy on the server that delegates the calls to the Basecamp API. However the downside of this approach is that this setup needs extra configuration and a server-side deployment.

This week I got the chance to pick it up again and I stumbled upon this forum post on the Basecamp Forum. I found this piece of code posted on Verveguy's blog. And it actually did the trick.

private function addAuthHeader(service:HTTPService,
                     username:String, password:String):void
{
    //add the header to request
    var enc:Base64Encoder = new Base64Encoder();
    enc.encode(username + ":" + password);
    service.headers["Authorization"] = "Basic " + enc.toString();
}

For everybody who needs to connect a Flex application to an API that uses https in combination with Basic Authentication, here is the solution. All credits to the original blog post.

Filed under: air, flex No Comments
14Mar/090

Useful SQLite Administration Tool: Lita

lita_iconI have been working on a couple of AIR applications, one of them being Airbob an open source Cruise Control monitor tool. This was the first AIR application I wrote way back when Adobe AIR 1.0 was released. For local data I also used SQLite which is very useful for saving state and preferences of your application.

There are several administration tools available, but none of them were really that good. David Deraedt wrote a complete SQLite Administration Tool using Flex and Adobe AIR called Lita, and it is very good and pretty useful when you need to dive into thise .db files.

Check out the list of features:

  • A free, multiplatform administration tool for your SQLite Databases
  • Open, create, compact databases
  • Create, rename, delete, and empty tables
  • Create, rename and delete columns
  • Create, modify and delete records
  • Encrypt or reencrypt your databases
  • Easily run your custom SQL statements
  • Create and delete indices

Screenshot:

lita

So great work David, and for more information about this tool and the install link, got to his blog.

Filed under: air, flex No Comments
13Mar/092

Microsoft Techdays 2009

techdaysThis week I went to the Microsoft Techdays in Belgium. I have not been doing a lot of stuff with Silverlight lately, but still I was curious if I could catch something new or see some cool demos that finally show the power of Silverlight or WPF.

The first day started with the keynote from which I missed the introduction thanx to the massive traffic jams on the E313. It was a well rehearsed slick demo that showed how easy it is to develop an application using the different solutions. After the introduction by Hans Verbeeck, Gill Cleeren showed us the Silverlight implementation of an application that visualizes data gathered from a Garmin GPS called CycleTracks.

Peter Himschoot showed us how easy it was to recreate that same application into WPF. A lot of code and XAML can be shared between WPF and Silverlight. You can read more about the application in this article. Peter is an excellent presenter, but in this case I didn't see the added value of the WPF application because the only thing it it can do extra is parsing the Garmin XML file. Then Gregory Renard tried to show us how he created a similar application for the Microsoft Surface device. Surface is definitely a very cool device, and I wouldn't mind getting my hands dirty in writing an application for it. But with a price tag of minimum 11.000 Euros I suppose I would need a very generous sponsor :)

Katrien De Graeve showed us a preview of the new features in Windows 7 and especially the multi-touch features will be cool the play with in the future. Yep, multi-touch is the new hype, everything has to be multi-touch nowadays. I almost forgot Windows Azure which is Microsoft's answer on cloud computing and services. It makes it easy for developers to deploy their applications on Microsoft hosted servers.

The keynote was perfectly presented but yet, I expected more from it. One word of advice maybe: next time make an application that really shows of the power of Silverlight and WPF and put a bit more effort on the looks. Sure it is a conference for developers, but the as they said themselves User Experience becomes more and more important, also in the business applications of the future.

I didn't catch all the sessions but here is a small summary of what i have seen:

I really enjoyed the presentation of Bart De Smet about LINQ. I haven't used LINQ yet, and if there is one thing that Silverlight might have as an advantage over Flex is that cool stuff like LINQ is also available in Silverlight. I never saw Bart De Smet give a presentation before but this might as well be the most technical session of the conference and yet it was very good. He lost me from time to time, but the general idea was very clear to me. Pretty cool stuff what you can do with Extension methods and Lamba expressions.

I also liked the talk from Andrew Pardoe about the CoreCLR. First time I saw a guy from Microsoft using an non-MS application like VI in a demo. We got an insight about the implementation of the CoreCLR which is the plug-in that you download into your browser and which contains the Silverlight runtime.

In the other sessions I learned a couple of new things about Silverlight, but especially the WPF and Silverlight sessions could have been a bit more advanced (like the LINQ session). I had too many deja vue's from previous sessions. Seriously, if I see a developer create a linear (or why not radial) gradient brush one more time... That's a job for a designer, so take a designer with you on stage or don't ;)

The Techdays are also a great opportunity to meet ex-colleagues, network with peers and collect pens (lot's of them). I have met some interesting people, saw some interesting sessions so I would say it was a succes (except for the power outage and the disappearing fridges on day two). I hope that Steve Ballmer will be there next year to cheer on the crowd.

Filed under: events, silverlight 2 Comments
10Mar/0911

How to restart an AIR application from code

I am currently working on an AIR application developed using the Flex 3 SDK. The problem I am facing now, is that I need to restart my application from code. This sounds very easy, you would think. My first guess would be that there should be a method on the NativeApplication object like:

NativeApplication.nativeApplication.restart();

But this method does not exist. There is an exit method, but no restart method. So I "googled" around and came to some interesting articles describing how to do this.

The Joy of Flex blog wrote an article "Can an AIR application restart itself?" I tried it out, but this did not work for my project. The code actually steps through the methods but the application never restarts. The article also says that there are serious problems with this approach. So probably I am in the case where the exit beats the launch.

So my next approach was this article by David Tucker: "AIR Tip 11 - Launching an AIR Application from an AIR Application". It actually described how to launch an AIR application from another application. This is what has been used in the first article, so back to start.

Then I found this interesting peace of code on Flex Internals:

package
{
  import mx.core.Application;
  import mx.core.WindowedApplication;
  import adobe.utils.ProductManager;

  public function reboot():void
  {
    var app:WindowedApplication =
        WindowedApplication(Application.application);
   
    var mgr:ProductManager =
        new ProductManager("airappinstaller");
   
    mgr.launch("-launch " +
        app.nativeApplication.applicationID + " " +
        app.nativeApplication.publisherID);
   
    app.close();
  }
}

Also make sure that the "allowBrowserInvocation" option is turned on in the AIR application descriptor template:

<allowBrowserInvocation>true</allowBrowserInvocation>

So this was actually what I needed, and it worked!
Any feedback is appreciated :)

Filed under: air, flex 11 Comments
5Mar/090

The Future of Rich Internet Applications at Devoxx 2008

Back in December 2008 I was present at the Adobe booth on Devoxx to represent Nascom. I was privileged to speak briefly to Chet Haase and Matt Chotin about the new Flex 4 SDK. But I didn't get to go see their presentation they did with James Ward. Well thanx to Parleys.com here is the complete presentation.