Archive for category Flash Lite
Flash Builder Profiler – Fixing Memory Leak on ExternalInterface
Posted by Mark Doherty in Android, Devices, Flash Lite, Flash Player, Mobile Content on June 17, 2010
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();
geo.addEventListener(GeolocationEvent.UPDATE, updateHandler);
function updateHandler(event:GeolocationEvent):void
{
geo=null;
trace(event.longitude);
}
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.
function updateHandler(event:GeolocationEvent):void
{
geo.removeEventListener(GeolocationEvent.UPDATE, updateHandler);
geo=null;
trace(event.longitude);
}
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.
EVA on Android – App in a Week
Posted by Mark Doherty in Android, Creative Suite 5, Devices, Flash Player, Mobile Content on June 10, 2010
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.
If you missed todays session you can catch it here and view the running application here.
Setup:
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.
PHP+MySQL Backend
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.
User Location
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.
When the application is running in the browser (Capabilities.playerType==”PlugIn”) I have used an HTML5 feature to get the location. This is achieved by using the ExternalInterface class, a bridge that Flash uses to communicate with Javascript.
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.
Local Weather
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 most fun part was easily finding a piece of code that calculates the Sunset (SunriseSunset.as). I was able to find and port a piece of JavaScript code that does the trick, although annoyingly I cannot find the author to thank them. Using this I can swap in the night icons for weather, nice
Flash Settings:
- 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
Asset Optimizations:
- 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
Text Optimizations:
- TLF is not used anywhere due to performance and size issues
- Only device fonts are used, they perform and render much better
Flex:
- 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!
DOWNLOAD
Upcoming E-Seminar Series: App in a Week
Posted by Mark Doherty in Android, Conference, Creative Suite 5, Flash Lite, Flash Player, Industry News, Mobile Content on May 7, 2010
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.
Schedule:
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.
SIGN UP HERE
Adobe AIR – Packager for iPhone OS demos
Posted by Mark Doherty in Devices, Flash Player, Mobile Content, iphone on April 1, 2010
We’re getting closer and closer to the launch of Flash Professional CS5, our Flash authoring tool ships with our Packager for iPhone preview. With the new tool it’s possible to create Adobe AIR applications based on Flash, and ship those on the Apple AppStore.
As you may have noticed, we have been shipping our own mobile applications for a while now, including Photoshop.com Mobile on Android, iPhone, Windows Mobile, and Acrobat Connect on the iPhone. In just these few short months we’ve managed over 6 million downloads already, and I’m looking forward to seeing future Adobe products on different form factors.
Of course some developer agencies have already been pushing out their first Flash-based applications using the pre-release packager. With over 100 in the AppStore today, I thought it would be interesting to have a look at the progress being made, enjoy the “presentation”
Although I’ve focused on the iPhone here, everything that you have seen can run on other platforms with a few tweaks. That’s the benefit of using Flash and AIR for your mobile and devices content.
Update: Kevin Hoyt shows some side-by-side demos with Android OS
Helisso – A Packager for Symbian devices
Posted by Mark Doherty in Android, Devices, Distributable Player Solution, Flash Lite, Industry News on March 3, 2010

As some of you know, learning about AIR, AS3, Flex, Flash Catalyst, Flash Builder has been my side-project for a few months now. As I mentioned in a previous post, it is essential to prepare for the future and invest now in learning new skills.
For me, the best way to learn new things is to create a project that’s difficult, yet cool enough to keep you interested. So my first few steps revolved around learning how to use Fireworks, then Flash Catalyst, Flash Builder and ultimately distribute an application using Adobe AIR.
AIR 2.0
One of the amazing new features of AIR 2.0 is the ability to embed and execute native code from right inside Actionscript, an API called NativeProcess. This means that you can safely run existing services over the command line, as well as install your own native service components. AIR 2.0 is in beta right now on Adobe Labs, and is mobile ready as designed so it’s a great time to get started.
So what would a Platform Evangelist for mobile and devices create?
Introducing Helisso
What is it?
- A packaging utility that can produce SIS packages for Symbian devices
- It targets the Flash Lite 3.x runtime for Nokia’s S60 devices
- It runs on PC and Mac OS, all versions
Details
- The tool has embedded Python binaries inside, compiled versions of “Ensymble“
- For signing purposes the tool also includes OpenSSL for certificate signing
- It is unsupported and without warranty
How do I use it?
How do I install it?
I have been hugely impressed with the capabilities provided by AIR, in this only my first AS3 project. Looking back on all of the technologies that I have used has really got me excited about AIR applications on Android, and even sprouted a few iPhone applications in advance of that. Seriously, imagine having all of the power of AIR and this toolchain on mobile phones?
Lastly, a big shout out to Steve Hartley of Oppian, Jussi Ylänen creator of Ensymble, without whom this wouldn’t have been possible.
Plugin by wpburn.com wordpress themes

