May 29, 2008

Features vs Functionality

Filed under: Development,Flex — Steve @ 8:57 PM

I’ve just spent a few days trying to implement a specific feature in my current AIR project. Having tried several approaches and workarounds with varying degrees of nearly-but-not-quite-ness, I’ve had to admit defeat for now and have moved to a different implementation that I’m less happy with, but still allows basic functionality. At the same time Kieran has recently started work on his first Flex project and it’s been interesting to see how an experienced developer, when faced with a feature or issue he can’t easily implement or find a solution for, has quickly fallen back to a ‘next best’ solution, and moved onto getting the application functional and usable.

Time pressures obviously play a part here – the amount of time you have available before the project has to go out the door is going to impact on how much you are able to include desirable features over essential ones, but I think what I’ve picked up from this is that as soon as you encounter an issue, if you can’t predict reasonably accurately how long it’s going to take you to solve it, you need to set limits on how long you spend trying to make it work and at same time identify what is achievable if you fail to get it done within that limit.

If all this sounds like common sense, it is of course – but I found that in this instance I got too focused on a specific feature, rather than on getting the application functional enough that users can start using it sooner rather than later.

May 9, 2008

AS Development skills sharing at Warwick

Filed under: AIR,Development,Flash,Flex — Steve @ 11:18 PM

Chris was talking today about intra-team/department skills sharing, which I think is a great idea. With regard to Flash and Flex development at Warwick we’ve recently embarked on something along these lines, with the formation of a University Flash and Flex developers group consisting of people actively using (or just interested in) Actionscript development. It started with a forum that was initially populated with ITS people (plus one or two others), but since starting to deliver some Flash courses for ITS Training I wanted to maintain contact with what attendees did with the skills they’d acquired after the course, and the forum was opened up to allow more people to contribute. We held the first ‘skills session’ a couple of weeks ago, in the Teaching Grid. It was purposely an informal gathering, consisting of developers from ITS and departments, plus lots of coffee and biscuits. The session was an opportunity for everyone to show what they’d been working on and share expertise and a mix of ongoing Flash, Flex and AIR projects were demonstrated, plus discussion on development approaches and potential applications in the future.

Overall I thought it went well (we ran out of time in the end) and although next time some structure to the session might help us cover ground more efficiently, the informality and range of projects kept it interesting, and it was especially good to share ideas with others while receiving questions and feedback. As a result of the session, I’ve been asked to present a more formal hour-long session on AIR to the CIS Team next week, which I think I’ll prepare some slides for.

Anyway, my point is that personally I found it quite fun/rewarding to find out what other people were doing or planning to do with the technology, and to see and discuss approaches/methodologies and alternatives; we should definitely do more of this kind of thing in future. Time will tell whether we maintain the Flash/Flex/AIR group sessions but I hope we can.

Warwick staff interested in Flash/Flex/AIR/AS3 development can join the developer group forum here. For students, Warwick Game Design have expertise with Flash for game development.

May 6, 2008

Flex–Spy – Live Component Inspector

Filed under: Development,Flex — Steve @ 9:42 PM

Writing about web page http://code.google.com/p/fxspy/

I’ve been using Flex-Spy today for the first time, and it’s really useful. It allows you to inspect and affect pretty much any parameter of a component while the application is running which is way faster than constantly building and running the app for trying small tweaks, and saves waiting for the CSS previewer or refreshing the Design View. Installation is a snap as it’s packaged as an SWC.

View a demo of Flex Spy (press the FlexSpy button top right to launch the inspector)

April 29, 2008

AIR/Flex: Memory optimisation

Filed under: Adobe,Development,Flex — Steve @ 4:56 PM

Moving to doing some optimisation within my AIR application now, using the Flex 3 Profiler. I was noticing some interesting results, primarily that removing redundant event listeners and display children doesn’t always result in memory being freed up back to the system. Not as bad as a memory leak, but not quite what I wanted. As a result I’ve just been reading up a bit on optimising memory and garbage collection in Flex/AIR. From what I can see, although garbage collection in AS3 is actually quite good, there are a few tips, tricks and caveats…

Weak-referencing
It’s possible to help garbage collection along a little by using weak references on events listeners:


myObject.addEventListener("eventName", handlerFunction, false, 0, true);
The last parameter being the weak reference flag. This saves having to manually remove the listener and means objects will be automatically removed by the garbage collector, but it can make debugging problems difficult because the collector won’t necessarily remove the object on its next pass. A solution to this is to force the collector to sweep and remove de-referenced objects.

Manual garbage collection
Sean Christmann (eBay Desktop) demonstrates a method whereby it’s possible to manually force the garbage collector to sweep and remove memory objects using

flash.system.System.gc();
flash.system.System.gc();
(yes you need to call it twice, once to flag objects, once to remove them). As Sean describes though, using weakly-referenced objects can make it harder to track problems:

Trust me when I say that its a lot easier to debug an application with memory leaks due to strong listeners, then it is to debug an app in which users report random failures because underneath the hood weakly referenced objects are getting accidentally destroyed when the GC kicks in.

Flash Player
Flash Player’s garbage collector may sometimes ‘swap out’ dereferenced-but-not-yet-destroyed objects for new ones under its normal garbage collection process, that is it will maintain a certain memory ceiling and not go above it, but some object types are harder to destroy than others because they get referenced into the player – these are generally the types of object that work asynchronously, Loaders being one example; see Flash’s Dirty Secret, and Timers are another. Memory paging can also get quite fragmented because Flash was never optimised for the kinds of application where it might be running for hours, days or even weeks as an AIR application in the System Tray.

AIR Windowing
I’d not really considered this before moving to AIR, but the windowing capabilities mean that managing objects and garbage collection across multiple windows should be handled with care, because it’s possible to lose the ability to reference objects when application windows can be closed, or the application is running in the Tray and therefore has no focus. Sean describes another caveat where any EnterFrame handlers (which you might be using to control the collector) must be re-referenced across multiple windows.

The Elastic Racetrack
Finally, although this isn’t a memory thing, a word about execution time in Flex/AIR; each ‘frame’ of execution in your application is tied to the elastic racetrack concept. Flex has to balance the load between AS code execution, rendering and event broadcast/handling around a single continuous loop of execution, with allocation within each cycle dependent on the load for each. The depth of the display tree, or the execution time of a method will affect what gets done when during a particular frame or ‘lap’.

April 15, 2008

Cairngen

Filed under: Adobe,AIR,Development,Flex — Steve @ 11:24 PM

Writing about web page http://code.google.com/p/cairngen/

I wish I’d come across Cairngen a bit sooner, having recently just set up two Cairngorm-based AIR projects via cutting and pasting a skeleton Cairngorm project structure from Rob’s earlier examples.

Cairngen will set up a Cairngorm project structure for you (using Ant), and much more besides. For example it’s capable of auto-generating what are termed ‘sequences’, which are sets of event-command-delegate templates (plus other alternative combinations) that create the FrontController, ModelLocator and VOs required, plus all the relevant mappings and basic classes. The core templates can also be modified so that classes contain whatever boilerplate text you need. A little downtime now learning how to use Cairngen should save me work in future, and if I set up a basic project script anyone else using Flex/AIR here can should be able to get projects up and running more quickly.

April 9, 2008

AIRTour London liveblog

Filed under: Adobe,AIR,Flex — Steve @ 10:22 AM

Writing about web page http://onair.adobe.com/schedule/cities/london.php

Just some live notes from the AIRTour London event today…

Andrew Shorten
Adobe – ‘disruptive technologies’
RIA platforms – AMP, Buzzword Connect, all built on Flex/AIR
Why AIR? – occasionally-connected opportunities, efficient development, richer interfaces.
Branding on desktop – clever clothing store that can match clothes to an image dragged

Kevin Hoyt – Building AIR apps with Javascript
Showing mapping app using Yahoo Maps API
Export map view as PNG by dragging – encodes PNG on the fly, drag map straight to desktop
Using notepad app to write an AIR app
Starts with bare HTML page
Point to XML application descriptor file – template comes with SDK
changed to point to HTML file
Running AIR from Terminal to test app – runs directly
Dreamweaver demo – extension for AIR available
Writing tags like input id=”foo” type=”button” value=”save”
then writes JS script that handles event, using DOM to grab object, then runs as AIR app
AIRIntrospector – similar to Firebug
Maps AIR namespace to JS, allows AIR APIs to be called: var stream = new air.FileStream(); direct in HTML.
Now showing Aptana as IDE fr AIR/JS dev – Aptana now supports AIR
Sandboxed environment to prevent scripting hacks, adds some limitations

Mike Downey – Lighthouse programme – looking for key apps to extend reach of AIR (e.g. EBay desktop) *
Kevin Hoyt – Integrating HTML, JS and AS*
Mixing SWFs using SWFObject – then drags an image from Webkit into his Flash app window, makes a table from the BMP that contains each px colour value(!)
Uses FileStream to re-render px values as image in other application window
Basically levering the WebKit engine in AIR to mix HTML, JS and Flash in the same desktop window and all can communicate with each other.

Serge Jespers
Deploying and updating AIR applications
Self-signed applications report identity as ‘unknown’ on AIR installer, when known ico turns green
Uses any signing mechanism, Thawte etc.
Export Release Build, import certificate
Install badge on Labs
CheckForUpdate() script, parses application descriptor file for current version, compares, prompts user to upgrade

Daniel Dura – AIR APIs
Network detection, File I/0, Window chrome
Multi-window, z-ordering, utility windows (no taskbar entry), Native menus, Drag/Drop from various sources, clipboard, System Tray, notifications, Signing, Icons
..and much more!
Windowing control is very rich
File Sync/Async APIs
SQLLite included
Lots of code on Daniel’s site
Can drag a URL into browser, browser opens
Network/Socket Monitor API – URLMonitor(URLRequest);
Dock notifications

Bah, Macbook batteries don’t last long…

Jeremy Baines – from concept to TechCrunch in 5 days
Developed Alert Thingy – AIR-based social network aggregator with alerts etc, in-application commenting on peoples blogs, actually some very useful features and a good example of using AIR.

Developing Secure AIR Applications (Oliver Goldman)
Imported/loaded content executes with the Loader sandbox – does not run with application privileges by default
Sandbox bridges – opt-in on both sides, arguments are pass-by-value, allow communications between loaded content and application
Can expose function calls, but can’t pass objects
Document.write(), eval() are prohibited to protect sandbox
Suggests only loading signed content – XMLSignatureValidator API available
Implementing update functionality makes urgent updates easy should you find a bug – make updating work first

Gah, batteries really gone now…that’s all for today – excellent day, ice-cold Coke, beer, games, short sessions, direct contact with Engineering team.

April 2, 2008

Merapi: AIR and Java

Filed under: AIR,Development,Flex — Steve @ 9:42 AM

Writing about web page http://adamflater.blogspot.com/2008/02/meet-merapi.html

I was wondering what the status of the Artemis Project was recently and had meant to follow it up, but a post on FlexCoders today highlighted Merapi, a new project that takes over from Artemis.

Merapi will provide a framework that uses Java to give AIR access to the system shell (and therefore have access to things like printing, scanning, hardware etc.). It’s very early days for the project but in a few months time it may be possible to create desktop applications using Merapi that do really useful things, without going near Swing. One to watch…

April 1, 2008

Cairngorm: Event Chaining with SequenceCommand

Filed under: AIR,Cairngorm,Development,Flex — Steve @ 8:36 PM

Writing about web page http://www.cairngormdocs.org/docs/cairngorm_2_1/com/adobe/cairngorm/commands/SequenceCommand.html

I was talking to Sara earlier about this and said I’d write something about it briefly. Sometimes when using Cairngorm you find that you need to chain a number of events. An example might be when an application initialises and you need to chain a number of events/commands that perform a number of sequential tasks. Typically what happens is that you end up following the event/command model and fire the chain by sending an event from a command, then sending another from the target command, and so on. However, Cairngorm includes a class that can help; SequenceCommand:

By extending SequenceCommand, you can specify the event that should be broadcast to the controller (causing another command execution without a further user-gesture) when the current command has completed execution.

This is really handy, particularly for those runtime initialisation tasks, and it doesn’t break the standard Cairngorm model of Events firing Commands because you define a nextEvent property that triggers another Cairngorm Event (which triggers the next Command, and so on). David Tucker’s excellent guide to Cairngorm goes into more detail and has an example. There are also many examples of people extending the SequenceCommand concept to perform other tasks.

March 26, 2008

AIR Debug Player – closing orphan instances

Filed under: Adobe,AIR,Flex,Flexbuilder — Steve @ 10:30 PM

Now and again I forget to properly close the debug player from within FlexBuilder, which in most cases is fine for a Flex app because it runs inside your browser instance, but if you do this with an AIR app it sometimes leaves an orphan instance running that you have to close manually, even if you close FlexBuilder – just look for any instances of ADL.EXE in your system process/task manager and close/kill it.

March 14, 2008

Flex 3 debug file size

Filed under: AIR,Flex — Steve @ 8:33 PM

Writing about web page http://www.cbetta.com/blog/index.cfm/2007/10/16/very-important-change-flex-builder-2-flex-builder-3

Thanks to James on this one – we’d both noticed that compiled SWFs of our new Flex 3 projects were almost double the size of similar projects in Flex 2. Here’s why:

Flex Builder only generates a debug version of the SWF by default. However, and this is the part that is tripping people up, there is no -debug suffix on the generated SWF file, so it will be named as if it were the release version. The big difference is that the file size will be much larger. This last point has raised a red flag with some developers, who mistakenly believe that the latest beta actually increases the file size of the release version of their application.

So basically Flex 3 only generates the debug version by default and no longer generates the ‘production’ version, in order to save development time. Flex 2 would create ‘yourproject-debug.swf’ and ‘yourproject.swf’ at build time, but this no longer occurs. To get the production version you need to go to Project > Export Release Build and go from there.

« Newer PostsOlder Posts »