Category Archives: Flash

Whilst I’m on the subject of Google and trying to finish half-written drafts hanging over from last year, I thought I’d briefly mention the release of Analytics for Flash.

Aside from capturing all the obvious generic statistics you’d expect from a Flash tracking package – and by being fluidly compatible with the main JavaScript library is capable of outputting all the core functionality of the existing Analytics components – the metrics offered by Google Analytics for Flash can be particularly designed to offer interesting insight into other aspects of your users’ activity you may not first expect. For example, you can collect data that can help you gauge levels of usability or (kind of) the implementation of design success. Seemingly you can monitor the behaviour of the users’ interaction during their visit too – as well as the length of the visit itself.

It’s all technically possibly, with Google’s introduction of event tracking that can be fired from custom interactions – whether that be a button click or video view or anything else. Along with that, the event can carry a payload, later received by your Analytics dashboard for your interpretation. It sounds simple – but it’s capable of being very powerful.

Previously, tracking your Flash content would be in isolation. That is to say, you could fire a tracking event when a user accesses a page of Flash content, but from there you were blind to their progress until navigating again.

This payload though, not only could detail traffic to specific sections within a Flash application (although in turn, separate events could be created for those) but could return data specific to that user and session. For example, the total time the user has spent in a particular place, or the site as a whole.

Depending on how complex you wish to be (and how many stats you want to trawl though later) this could offer very valuable data. But that data need not only be of value to an agency or advertiser. Counts for clicks on specific buttons aren’t anything new when you want to find out how many people click a ‘News’ link first, or if anyone notices the ‘Help’ button. This can be far more granular – to the point, as above, where the data could be used to inform decisions on say, design or usability.

Take a standard Flash video player as a media component you’re used to seeing on a daily basis. You can easily picture the common control bar. But how many people actually use those ‘Rewind’ and ‘Fast forward’ buttons? Could the design be improved?

Admittedly with Flash video components, you’re unlikely to see those nowadays ;) – but that (as I’ve picked this example) is the result of user testing, something this kind of tracking can’t replace – Jesse Warden has a strong sense of this in his post about Flash Analytics.

Anyway, the custom events let you send as (overly-) complex amount of data as you wish. Flash of course can be used everywhere, deployed as widgets or embedded on blogs anywhere on the Web. These Analytics though, are part of your application itself. So you can track its usage outside of the original HTML page the previous iteration of Analytics would have restrained you to.

And it’s free! Check out the code repo.

Exactly how search engines deal with the content of Flash-based websites and information in SWF files has notoriously been a bit of a grey area for a long time. Historically, website creators had to battle with clients as to whether the aesthetic potential of Flash was enough a pay-off against their judgement of the importance of this new idea called ‘SEO’.

In July of last year, Adobe announced a collaboration with Google (1, 2) and Yahoo! to develop a new Flash Player technology specifically to enhance the search results of dynamic content in Flash – ultimately, to make the SWF searchable.

But it was unclear how it worked, what it actually did and what provisions the Flash developer or content creators would have to make.

Peter Elst aired his thoughts and agreed as I did, it looked like a ‘backup’ or intermediary solution. There also lacked a standard or recommended approach to deploying the content for this new technology – presuming this new platform hadn’t just become instantly intelligent to all possibly methods of delivery.

Adobe later published an FAQ, but still it wasn’t very technical, so a few developers started experimenting. After seeing Peter’s attempts, Ryan Stewart announced a Flex SEO Contest – an outright declaration that we’re confused but determined to find out what exposure our content has. As well as being a bit of fun. ;)

Dominic Gelineau constructed fourteen test cases, essentially finding every possible way you could contain a simple text string in a SWF file (see 1 – 7 here, 8 – 14 here). He used both static and dynamic TextFields, populated them in various ways, MXML components, standard Flash UI components, whether to use states, etc – covering all the bases across Flash and Flex.

Initially he concluded Google wasn’t really finding anything new, but in a later article for InsideRIA he listed his principle observations:

  1. Most of the content that was on the stage/timeline at compile time would be indexed even if it was outside the viewing area.
     
  2. The TextArea, Text, ViewStack and custom MXML component in Flex would get indexed if they were in the MXML (the Flex equivalent of being on the stage) but the Label component would not.
     
  3. Until October, SWF files embedded in the HTML using JavaScript (SWFObject, AC_RunActiveContent, etc) could not be found on Google.
     
  4. Again until October, anything related to the ActionScript 3 method addChild would not get indexed. As an example, adding a MovieClip from the library with static text in it using addChild method would not show up in Google’s search results. In the same way, using states in Flex wouldn’t work. My guess is that since states uses addChild in its MXML syntax, once compiled it would get converted to the addChild method in AS3.
     
  5. Finally, any content loaded externally from the embedded SWF file wouldn’t get indexed, but was clearly stated by Google.
     

Fortunately, Jim Corbett, Flash Player Engineer at Adobe offeres some much-need clarification, answering many of these questions at the Adobe MAX conference this year. The video can be found at Adobe TV, (I’m having problems embedding it with WordPress) – it’s lengthy, and gives a good insight into the Player’s search mechanics.

Last month’s Flash platform group meeting was presented by Michael Plank and Frank Piotraschke from Powerflasher, authors of FDT the Actionscript IDE plugin for Eclipse. One of many features of FDT Frank demonstrated was SWC and SWF(-ish) browsing support.

He opened debate as to whether adopting a SWC or SWF nominated workflow for handling compiled components and libraries is more desirable, presenting methodology for both. Although then a decent excuse for him to show off FDT, each approach has its benefits and it’s good to know how to code both – previously I’d never used SWFs in this way, always choosing SWC files.

To use a SWC as a linked library and access a clip as a dynamic class, establish a linkage in the library to a class definition that does not exist – for example:

com.hibbins.Clip

When you click the ‘Validate class definition’ tick, you’ll get an alert that the definition cannot be found and it will be automatically generated upon export. Export the SWC and add it to your project classpath and it’s ready to use. Just instantiate it as you would any other class, note the import if your packaging requires it:

package
{
import flash.display.Sprite;
import com.hibbins.Clip;

public class SwcTest extends Sprite
{
public function SwcTest()
{
var clip:Clip = new Clip();
addChild(clip);
}
}
}

To do the same with a library from a compiled SWF, you need to load the SWF file containing your assets into the same Application Domain as your loading SWF file. The following diagram represents the classes available to each SWF file considering their respective domains:

Application Domains

The SwfTest class exists within the loading SWF file, the Clip class in the library file (published as assets.swf). Loading the file in to the current Application Domain shared the loaded SWF domain classes within the main class pool:

Application Domains

The following code demonstrates how to do that, then instantiate the class with the getDefinitionByName method:

package com.hibbins
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.utils.getDefinitionByName;

public class SwfTest  extends Sprite
{
public function SwfTest()
{
var loader:Loader = new Loader();
var context:LoaderContext = new LoaderContext(false,
ApplicationDomain.currentDomain);

loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
onLoadComplete);

loader.load(new URLRequest(“assets.swf”), context);
}

private function onLoadComplete(event:Event):void
{
var ClipClass:Class = getDefinitionByName(“com.hibbins.Clip”)
as Class;

var clip:MovieClip = new ClipClass();
addChild(clip);
}
}
}

Both are pretty quick ways to handle custom MovieClips from your library dynamically. If you want to add any functionality to the clips you can write their classes using matching definition paths. Be aware though, any timeline actions will be dropped if you do this.

If you really want to keep frame actions, I’ve found two ways – firstly by using frame labels which are maintained elsewhere and coding around those, the other only works with SWC files, creating a class which extends from the dynamic clip class. With the SWC in your class path you won’t have any compilation errors.

As Frank pointed out, SWC files can be a lot heavier when loaded on application startup which can make your main SWF quite large. Using SWF files over SWCs, you can create an sequential load manager or only load them asynchronously when necessary. Also, with SWCs being relatively new in comparison to SWF use, you might have no choice. On the other hand, the SWC workflow is simpler and many IDEs have some form of SWC explorer – FDT and Flex Builder, for example.

There’s also an a shortcut to display the contents of a SWF in the same way in FDT, though it’s undocumented. Hit Alt+Shift+W and you can get an outline view (I don’t think this works on all versions of FDT though). It would be good if when this is better integrated into FDT, the classes are recognised in a similar way to the SWC support for auto-completion – as Tink says in the video, to avoid the ‘flakey’ long line of code that’s easily prone to mistyping.

Presentation slides, source code and videos are now online [via].

Peter Elst recently posted the Sneak Peeks session from the Adobe MAX conference this year. It shows some really good projects, that as the disclaimer strongly advises, may or may not be featured in future releases of the various Creative Suite software:

Serge Jespers presented Nitro, a platform to design, build and distribute Flash widgets ‘on multiple screens’ – i.e. multiple target devices. Intended to create a coherent work flow and end-user deployment environment of ‘widgetized’ Flash content.

There’s a nice demo of pulling a widget directly from a browser to the desktop, detected by the central Nitro widget ‘dock’ which simultaneously synchronised to a mobile device and television. If it’s even half as simple as the demo suggested, then delivering widgets recognised as solid portable, ubiquitous single-purpose applications rather than kitschy or novelty desktop ‘toys’ could very soon be far easier realised.

Meer Meer is a virtual laboratory of browsers, basically a Flex app that runs a variety of coded browsers (of multiple operating systems) on a single server and centralised into a one application. Integrated directly into Dreamweaver, you can render all your local files in each browser with one click of a button. Not only does it offer split-screen views, but an onion skinning mode to overlay browser images without the need of endless screen grabbing (as I currently do) if you play to the pixel. This makes my browser testing posts (1, 2) completely useless, excellent. :)

If none of that interests you, just watch Rufus Deuchler presenting Shai Avidan’s Infinite Images and Infinite Panoramas – I won’t even try explaining – you need to just watch, starts around the 55 minute mark.

Also featured was RTMFP Application-level Multicasting, which broadcasts live video with P2P-style distribution methods; Durango, a Flex/AIR framework to easily create mashup applications almost code free; LiveCycle services in combination with CS4; and running server-side Actionscript seemingly without Flex or Flash – the demo didn’t really work out.

Can’t afford Flex Builder? Build your own!

Well, almost. You can get some easy auto-completion, syntax highlighting and simple error checking of MXML scripts with a nifty bit of XSD integration with Eclipse, using an XML Schema doc from an open source project, imaginatively titled XSD4MXML.

The XSD format is the typical extension for XML Schema, a document defining a set of rules to which an XML document must conform. Eclipse can utilise a Schema document then, in combination with some of the baked in plugins – namely Web Tools and the standard XML editor – to offer these benefits.

The XSD4MXML document outlines what properties any given tag can express – at the most basic level for example, an Application tag can have a layout attribute or a frameRate attribute, an HTTPService tag has a url attribute – but it references every attribute, includes inheritance, for all properties, events, methods etc. This document weighs in at 1.2mb, it’s almost 28,000 lines of code.

Combine that with the error checking the standard XML editor offers and the auto-completion when an XSD format is provided and very quickly you’ve got some useful functionality.

So it goes:

  1. Get the latest version of Web Tools. A fresh Eclipse build should come with it, otherwise follow the instructions here. NB: I’m using Europa, the update process is a little different for the new Ganymede release – also, don’t try and get the latest Web Tools version if you haven’t got Ganymede.
     
  2. Grab the latest version of the XSD4MXML doc.
     
  3. Open the Preferences panel in Eclipse, go to Web and XML > XML Catalog and select ‘User Specified Entries’.
     
  4. Click ‘Add…’ and browse to your local copy of XSD4MXML, the namespace should fill automatically when you’ve found it, click OK.
     
  5. Go to General > Editors > File Associations and add the *.mxml type. Under ‘Associated editors’ add the XML editor.
     
  6. Still in the preferences, go to Content Types, open the Text type and select XML, again add *.mxml.
     
  7. Create a new project and MXML file, add the XML header, an mx:Application tag and namespace:
     
  8. <?xml version=”1.0″ encoding=”UTF-8″?>
    <mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”>

    </mx:Application>

  9. Within the Application tag, hit Ctrl+Space for the Content Assist menu and you should see a full list of MXML tags and you’re done.
     

You can use the Ctrl+Space shortcut for auto-complete on all tags, properties, events, etc. The XML editor should highlight syntax and do a little error checking itself.

We can run with our arms open before the tide.