Archive for category Flash Lite
In November last year I presented at a QNX customer event in Stuttgart, attended by the top Automotive OEMs and suppliers. The event was great and it was clear that automotive is going to become yet another frontier for connected web technologies – what an exciting industy.
The QNX Neutrino OS is of course the underlying platform used by the Playbook as well as huge range of server, industrial and automotive products, all with “space-grade reliability”. QNX has of course shipped Neutrino in a huge array of different products in various configurations, making it one of the best choices for industrial, automotive, transport and consumer devices.
Interestingly, with the QNX Car, automotive OEMs can leverage Flash in a very unique way. Merging highly available OpenGL rendering with Flash components, and blended together using some special sauce. So with QNX Car, it’s possible to produce dashboards that are highly available and safe, yet dynamic and easy to produce in Flash. To enable this, the Neutrino OS employs a number of distributed processing techniques that ensure the safe running of key components – all while offering amazing multimedia and connectivity features.
Throughout 2010 we’ve all been thinking about the huge range of new devices, tablets, televisions and mobile phones that have begun to change the digital landscape. As part of my investigation into the automotive space, I started to think about the interactions between these devices. Do passengers want their tablet to be the control hub for their car of the future? What can we learn about our driving “expertise”, or green credentials using applications?
Imagine all of the opportunities for great integrated applications, think of all of the information at your disposal! We could have personalized and theme’d dashboards, mood sensors, and with 4G connectivity options on the horizon, we could see vast amounts of telemetry data help with the ever increasing congestion on our roads.
Well the good news is that the folks at QNX are already putting these concepts together. Let’s take a look at this demo shown at CES, integrating the RIM Playbook directly with the QNX car control systems…
Grzegorz Trubilowicz of IKS in Poland recently came out of hiding to show off “Cooklet”, a great example of a multi-screen application for cooking enthusiasts!
Part of my secret past involved six years behind a cooker, believe it or not I was a Chef. So this application is very interesting and there are lots and lots of components, including an AIR application, a Flash Lite app and of course this works in the browser too. As you would hope, the applications leverage the Flash Platform as well as HTML and JScript to deliver a great RIA experience.
Users can create, share and comment on recipes for food and cocktails. On your mobile phone you can keep track of your meal plan using the on board shopping list (Contextual application anyone?).
As if that weren’t enough, IKS created their own TV Channel on Youtube – and that can only lead to one thing
One of the most common problems with Flash applications are memory leaks, programming flaws that cause Flash Player to loose access to memory that it could recycle otherwise. In the mobile space it’s crucial to understand memory management to get the most out of the Flash Player, and ultimately to ensure a smooth ride for your consumers.
Flash Player memory management
Flash Player makes use of automatic memory management, to help you to create applications with ease and with less code. In fact the Flash Player uses a pretty simple mechanism that determines how many times you have referenced a particular object. Once an object has nothing referencing it then it can be garbage collected – predictably it’s called “reference counting”.
The following is a great example of reference counting in action, notice that I have created a Geolocation object (geo) and added updateHandler as a listener function for update events. This counts as a reference against updateHandler:
var geo:Geolocation = new Geolocation();
The updateHandler function marks the geo object null, tagging it for deletion by the garbage collector which is great. The problem is that the geo object still has a reference to updateHandler, and therefore the geo object cannot be deleted until we remove the listener and free the reference up.
Memory leaks are easy to create in Flash, and even harder to debug later. It’s therefore essential to build your applications with memory in mind and use all tools at your disposal to keep checking for leaks, slow performance, and run away code.
Flash Builder Profiler
Flash Builder 4 ships with a new feature called the Profiler and in the video below I’ll show you how to use it to solve a memory leak. Now don’t be fooled, this memory leak took a few hours to solve in reality – these aren’t easy problems to solve.
In fact I found two memory leaks, the first is the ExternalInterface.addCallback holding onto a function reference. The other is more complex, and I have marked it “Flash Player Bug” as I believe this is a problem with the runtime itself.
I have just completed my App in a Week session on targeting Mobile and Devices, as promised, here are the source files for EVA on Android. So that you don’t get lost in the huge swathe of code let’s run through some of the features to get you started.
Target Multiple Screens:
The goal of this application was to target Android devices running AIR, or indeed the Flash Player running in mobile browsers. So it was important to include some pointers on how to dynamically layout the application.
I chose to implement two pretty simple examples of how to do this using the widgetComponent and the footerMenu. In the Application class I listen to the “Event.RESIZE” event through the doLayout function. As you stretch the SWF (use the standalone player) you can see the widgetComponent always displays in the middle, the footerMenu will always be at the bottom.
Of course the menu, widgets and background should all change dynamically. This won’t require a huge set of changes and as you can see it’s quite simple to control the layout. In a later build I will investigate a more dynamic approach to laying out the UI.
To demonstrate the data-centric features of Flash Builder, Mihai and Piotr created a database with PHP services that describe common Evangelist activities as well as data about us. In the mobile demo I have coded as few of these database interactions in the UsersService class:
- “UsersService.getByUsername” – Is used to login and returns an object with user details including their name, photo url etc
- “UsersService.setLocation” – Is used to store the lastest location after login, this is then synchronized with other Evangelists.
I have created a User object to represent the user of the service, this class also manages the loading of the user image using ContentLoader. The primary function of ContentLoader is to abstract the loading of SWF/image files, handling the various possible error cases.
An interesting new feature of Adobe AIR on Android is the ability to use the GPS hardware to get an accurate location fix. Although EVA was designed to run inside, or outside of the browser and as such I have built a few fallbacks.
In addition to these two approaches I have also deployed the MaxMind GeoIP service on my blog. This is a huge database of IP addresses that can be used to determine an approximate location, usually your nearest city. This is used when the application is running in standalone mode for debugging purposes, or as a failure fallback.
Using each of these methods I can reverse geocode the latitude and longitude to discover the users current location. The UI displays the current city and country. The open geonames database is an incredible free webservices that cover all manner of data, I couldn’t have wished for more.
One of the more interesting features of the application is the local weather service. There are only two services that can produce weather data for a give latitude and longitude, and those are Geonames and Google Weather.
I chose Google because it comes with the added bonus of providing a weather icon to display. Unfortunately this icon isn’t up to the quality of Serge’s design and so I ultimately swap it out, but at least I can easily change the URL.
- The stage is running in low quality mode – perfect for use with device fonts
- Layers have been minimized and flattened as much as possible
- The Frame rate of the application is 15FPS – as low as possible
- The EVA background is an 8KB PNG-8 128
- All other images are mobile optimized PNG-8 128 Dithered and under 4KB
- Bitmap caching is not used, the application is relatively static
- Special care has been taken to ensure that all assets are snapped to pixels (not 23.43 etc)
- No assets are loaded off stage and nothing is invisible, ever – if they are unused, then they are unloaded
- All assets use “Sprite” as their base class, as set in the properties panel in Flash Professional
- TLF is not used anywhere due to performance and size issues
- Only device fonts are used, they perform and render much better
- Flex is not used due to the overhead of the framework on devices.
In later blog posts I will discuss the Widgets in more depth, including the Social and Radar widgets. It’s also worth noting that Tom did a great job to deliver his P2P widget ready for integration, amazingly within 12kb!
With CS5 now available the EMEA Evangelism team have been hard at work prepping for our upcoming tour and the Online Developer Week. The course of events will fall between June 7th – 10th covering everything from design in Photoshop CS5 to development, and even deployment of your applications using the Flash Platform suite of tools.
The tools covered will include Flash Builder, Flash Professional, Flash Catalyst, Flex 4 and the Flash Player 10.1 and AIR 2 runtimes. In my own session we’ll also be covering Device Central and some asset optimization guidelines for targeting mobile phones.
We’ll also look at P2P with Flash Player 10.1 as well as Livecycle, PHP and Java integration on the backend.
June 7th – 12:00 – 13:00 GMT Erase the Designer to Developer gap: Adding interactions to your design with Serge Jespers
June 7th – 15:00 – 16:00 GMT Connecting your design to PHP services with Mihai Corlan
June 8th – 12:00 – 13:00 GMT Connecting a web application to a J2EE backend using Flash Builder 4 with Michael Chaize
June 8th – 15:00 – 16:00 GMT Working with Flash CS5 components in your Flash Builder 4 project with Mike Jones
June 9th – 12:00 – 13:00 GMT Going multi-user with P2P in Flash Player 10.1 with Tom Krcha
June 9th – 15:00 – 16:00 GMT Developing multi-user applications with LiveCycle services with Tom Krcha
June 10th – 12:00 – 13:00 GMT Bringing web Applications to the desktop with AIR 2.0 with Piotr Walczyscyn
Jun 10th – 15:00 – 16:00 GMT Code once and run on multiple mobile devices with Mark Doherty
We’ve been busy for the past week building “EVA” to demonstrate all of the above. I think you’ll be really impressed with it and of course we’ll be providing the code after for you to use in your own applications.