It’s been a week since I was at Flash on the Beach but whilst I was there Rami Tzabar from the BBC (Digital Planet on Radio 4) asked me a few questions about Flash Lite just after my presentation. You can listen online and download the podcast at:

http://news.bbc.co.uk/2/hi/technology/4849402.stm

Direct link to mp3

Skip to 20 mins 30 seconds for the piece on 10 years of Flash (and Flash on the Beach). The show talks about the evolution of Flash and its expansion into various forms of media. There’s also an insightful discussion from Geoff Stearns on the abuse of Flash. 10 years, wow.

Although I didn’t have time to prepare, the message is that Flash Lite is an enabling technology that fills a gap in the market, not just competing with an existing product.

Now that the site is live for our book on Flash Lite (thanks to Scott) I’d also like to take the chance to point you to one of the chapters I wrote which is online for free download, available immediately:

Visit the page (PDF on the right)

This chapter contains a variety of concepts involved with game programming on limited devices; including math, physics, collision detection, keypad input, graphics and sound.

If you enjoy this chapter, please feel free to order a copy from the good people at Friends of ED.

Finally got round to uploading my slides, source and the source for the FOTB Flash Lite Pocket Guide, so my apologies for the delay… I had to take a flight straight from Brighton to Seattle on the last day of the conference and it’s been pretty busy since I arrived. I also want to take this chance to thank John, as many others have. It was a fantastic conference and extremely slick, I hope he invites me back next time. Without further ado, here are the zips!

FOTB 06 Complete.zip

If anyone is around Seattle/Redmond in the next couple of weeks and fancies a beer, I’m here till the 22nd so please drop me a comment. I still can’t believe how everything manages to be 3 times larger and half the price, how upsetting. :p

I’m pleased to finally announce the Flash Lite Pocket Guide for Flash on the Beach 2006. I had some problems embedding so many images and a large amount of XML parsing required for something like an event guide in Flash Lite 2, the RAM limitation is something you never totally get used to, but on the flip side I believe that limitations can lead to happiness. There are several tricks and tips required to get this working well, but after some effort here we have it:

SIS Installer (alternatively http://tinyurl.com/y9rsxn)

Zipped up SWF+XML

I’ll be uploading the source for this. It is an AS2 Flash Lite 2 project so if you are a Flash Lite 1.1 developer/designer at present, you can see some of the benefits AS2 gives you when creating your mobile apps.

If you are at Flash on the Beach, please do come along to my session on Flash Lite 2 Tuesday at 4:30 in the Corn Exchange.

If you have trouble installing the file, you may like to take a look here.

A while ago I posted about casting failing if you cast the result of attachMovie() but only in certain cases.

I had the same thing happen today, so I opened it up in FLASM, and I think I can see what is happening:

push 'sp'
getVariable
trace
push 'sb', 0.0, 'getNextHighestDepth'
callFunction
push 'sb', 'com'
getVariable
push 'domain'
getMember
push 'controls'
getMember
push 'ScrollBar'
getMember
push 'LINKAGE'
getMember
push 3, 'attachMovie'
callFunction
push 1, 'com'
getVariable
push 'domain'
getMember
push 'controls'
getMember
push 'ScrollBar'
callMethod
varEquals

As you can see here, it seems instead of performing a cast operation (and “cast” is a keyword you do see in the FLASM output), it actually tries to perform a conversion (as you see with Array or Boolean), treating com.domain.controls.ScrollPane as a function, and applying it to the result from the attachMovie() operation. This results in the undefined/null value we are experiencing because in itself, this function has no return value unless used with the new keyword as a constructor.

As I stated in the previous post on this subject, splitting the code onto two lines seems to fix the problem (i.e. attachMovie() then cast on the next line). Is this a compiler bug? Has anyone more experience with the inner workings of the Flash Player? Why do Macromedia’s v2 components not suffer this, I have a feeling it is to do with the inline dynamic dereferencing, maybe #initclip needs to be brought in for AS2?

Well I’ve seen Tink’s and Peter’s wishlists, so I think it’s time I put up my own, and this was really tricky, too many sessions I’m going to have to sacrifice.

Day 1:

11:00 Craig Swann – ..and now for something completely different..

13:30 Branden Hall – Explorations with ActionScript 3

15:00 Aral Balkan – Memo to the CEO

16:30 Erik Natzke – Keep Interest(ed)

Day 2:

9:30 Brendan Dawes – Contains one scene of sheep skinning

11:00 Joey Lott – ActionScript 3.0 Design Patterns

13:30 Rich Shupe – Vecmaps and Bitters

15:00 Keith Peters – ActionScript 3.0 for Animation

16:30 Richard Leggett – Flash Lite 2 (I’ll kill me if I don’t go)

Day 3:

09:30 Geoff Stearns – Flash in a Web 2.0 world

11:00 Sascha Wolter – Enterprise Flash

13:30 Hoss Gifford – Creative Evolution: Behind the Scenes

15:00 Chris Curzon – Artificially Intelligent Actionscript

16:30 Mario Klingemann – Mashup Baby!

In other news, there is going to be a Flash Lite guide for FOTB so you can keep track of what is happening, plus a couple of suprise extras. Keep an eye on this blog in the next week.

Things are really hotting up now, excitement levels are running high, so see you there!

Aral just had an interesting post on XAML, the markup language used for presentation and layout in Microsoft’s Windows Presentation Foundation (WPF). He touches upon a fact that it is sometimes quite a shock to see some real abominations when it comes to some of the XAML out there on the web. But there’s more to it than meets the eye when digging deeper. I’d like to post my reply on here also, and make it clear, I am not evangelising for either side in this post, but I find it fascinating comparing these two technologies which are making modern creative development very satisfying….

<snip>


Hey Aral,

Actually I feel I should jump in and balance the arguments a little as a fellow Flash developer. I’ve been using XAML a lot recently, and it is such a different beast, even though there *are* a lot of parallels throughout the development process, such as timelines, styles, templates (skins), data-binding, partial classes (code behinds), bitmap effects (filters) and so on.

Please ignore the reams of un-readable XAML code out there on the Web. These are auto-generated by designer oriented tools, trust me you can write some really beautiful concise stuff if you *don’t* use them. (read: Visual Studio with .NET3 “orcas” add-on if you want to pay, or Visual C# Express with addon if not).

XAML/WPF really does a brilliant job of seperating code from presentation, it positively enforces it in the way you have to work. It takes a little getting used to, true, but for someone like yourself that would be measured in hours not days. It is similar perhaps to DHTML, where the presentation is entirely seperate from the logic. This is shown by the ability to dump all visual content in say the Button class, and replace it with anything you like, it doesn’t break because the visual entities are seperate from the Button’s behavioural code.

The speed at which you can throw together a simple application is probably the same for both. With XAML you can put anything inside anything inside anything, this makes for some really well encapsulated “cell renderers” without requiring the concept of a cell renderer at all, it’s quite clear that the framework is doing an awful lot for you to cater for lots of needs and this has it’s ups and downs because it means that your aren’t as “pedal to the metal” as with Flash, where we tend to know pretty well what is *actually* happening behind the wizards curtain. As usual with MS we have to rely on the engineers doing a good job on the black box and providing lots and lots of documentation, which they do to a good level.

Where Flex/Flash eases ahead is in terms of visual dynamics and other such nicities. XAML’s power comes from the WPF framework behind it. You can literally add tags inside component tags to add borders of all kinds, vector graphics for background etc, dropshadows and other bitmap effects, all conforming to the chosen layout control surrounding them like VBox or Grid. This works great for applications, but if you want some of the things Flash does best, very dynamic animation and small additions here and there you need to jump through the stricter hoops WPF enforces, which means it is much much slower to do certain things and not so easy. Unlike with the Flash Player, being bred as a tool for animation, which enables you to very quickly add dynamism in very little code. This has something to do with the prototype based nature of ActionScript, but more-so the core types built into the player.

This is illustrated by a simple example. I wan’t to create a button with 3 states, each looking slightly different visually. In Flash this could not be easier. But in WPF, without an IDE that actually has a concept of these states built in, you must do it in code/XAML only (perhaps also using individual vector/bitmap assets if you want)….

So in Flash it is easy, particularly with slice-9. In XAML/WPF you need to think differently and do this by setting up a new style for all buttons (or just one instance), and then putting in 3 style trigger tags within, one for mouse over, mouse down etc. In those style triggers you can replace the template/skin, or make it highlight/glow etc, it is kind of like modifying CSS on HTML entities using JavaScript on a JS event. So there’s a different way of thinking required. But neither is better than the other because they both have so much to offer. The lack of a visual editor acts as a double edged sword. There is a visual editor, but it is only that, you can only create static graphics, the concept of MovieClip does not exist.

At the end of the day penetration stats are going to make the decision for most people, but all in all I thoroughly enjoy using both, and will continue to do so. The Visual Studio IDE makes me a hell of a lot more productive than with any other IDE in any other language. Just being able to use the immediate window (type in any code and it will evaluate it whilst the program is running) and a truly amazing debugger, makes WPF development a joy (roll over objects/arrays in code, have it tree-view that item at runtime). But I’d be saying the same if FlexBuilder had those features, and with the new stuff in AS3 this might possible if the object reflection has come along enough.

</snip>

Comments welcome as always, but please keep them balanced ;)

A colleague suggested it would be useful to build in version numbers into SWFs so that you could simply right click and see just what version you were looking at. Think in terms of QA or a client on the phone. With continuous integration it is useful to be able to say “hey just right click… so it says r12345?”. The r12345 here would refer to the revision number in Subversion. This makes bug tracking say using Trac much more integrated.

Sample (zip at end):

The premise is simple. When you run your ANT build script from Eclipse to compile your SWF, it injects the current revision number into an AS file, which the swf then includes and uses to build a new context menu item containing said revision number. Here’s how to do it…

Installation and Pre-requisites:

You will need:

*Be sure you have the LATEST (1.4+) version of Subversion installed, not Tortoise, the Subversion client itself. Download from: http://subversion.tigris.org/project_packages.html

Step 1:

Assuming you already have Eclipse set up. Install svnANT by downloading the zip from the above URL and extracting the following two files:

  svnant.jar
  svnClientAdapter.jar

…into your ANT lib folder, e.g.:

  c:eclipsepluginsorg.apache.ant_1.6.5lib

Step 2:

Now before you can use your newly installed svn tasks in build files, you have to make sure these two JAR files are included in your external tool classpath. You can do this by clicking the downward arrow to the right of the External Tools icon that you normally press to run a build ( looks like the little red toolbox with the green icon run external tool ).

In the Classpath tab, add the two as external JARs. (see screenshot addSvnAnt.jpg).

adding svnAnt
(click to enlarge)

The alternative method is to just add the two JARs to your build file’s classpath, but this way saves that hassle. But if you do not wish to add these JARs to your ANT you must manually include them on a per instance basis in your ant task with the following line: <taskdef resource=”svntask.properties” classpathref=”project.classpath”/> where project.classpath is the folder they live in.

Now Restart Eclipse (use -clean flag if you experience problems).

The Build File:

You can now make use of the new tags available to you to perform any Subversion related tasks you wish. The docs are avaible as part of the svnANT download zip. In this case we will get the latest revision number for our src folder and then add that to a file which we can #include which we will include to add our context menu to our base SWF.

Step 3:

In the build file, add another target that looks like this:

<property name="src.revision" value="null" />
<tstamp><format property="today" pattern="d-MMMM-yyyy, hh:mm aa" locale="en"/></tstamp>
<target name="Include_SVN_Revision" >
<svn javahl="false" >
<status path="${main.file}" revisionProperty="src.revision" />
</svn>
<echo>Building revision::::: ${src.revision}</echo>
<copy file="${basedir}/revision_template.as" tofile="${source.dir}/revision.as" overwrite="true" >
<filterset>
<filter token="revision" value="${src.revision}" />
<filter token="timestamp" value="${src.revision}" />
<filter token="user" value="${user.name}" />
</filterset>
</copy>
</target>

( ${main.file} is just an ANT property pointing to your base/application FLA. )

You might just want to look at the build file in the download at the end. Basically all this is doing is injecting some meta data into an ActionScript file which we can later include…

Step 4:

In your FLA (or AS class), you just need to #include the revisions.as file, and add the following code to add the context menu:

var cm:ContextMenu = new ContextMenu();
var revisionCM:ContextMenuItem =
    new ContextMenuItem( "r"+_level0.svnRevision, function(){} );
cm.customItems.push( revisionCM );
this.menu = cm;

That’s it. Sample should be clearer than the above garb. Here’s a sample download and below is a sample swf:

Ms. Dewey makes searching the web a little bit more fun. I tried a search for “Flash” to what she says: “Nothing gets a girl hotter than talking about code. Lights, camera, ActionScript.”. The load times seem quite high because of the amount of video used but it might also be a server issue at the moment.

Search now.

Next Wednesday (25th Oct ’06) my colleague Rob Bateman and buddy Tink will be hosting another LFPUG (London Flash Platform Usergroup). They will be speaking on Visual Interfaces for the Human Brain and Flex 2 for Flash Developers respectively. Tasty stuff. Last time was a lot of fun even though I had to rush off after my preso, but the venue was really nice so hopefully see you there. Remember to sign up to make sure you get in:

Sign up here.

Hopefully this time Stefan (FlashComGuru) will also be able to hook us up with some more live streaming!