I was up extremely late last night figuring this out, so I made some rough notes as I went along. Hopefully they’ll save someone a small nightmare.

Disclaimer: I haven’t written C code since I was in my teens, and apart from some Objective-C from the comfort of XCode, I haven’t really done a whole lot of GCC compiling on any system, so this may not be the best way to do any of this.

The schedule has just gone up, new speakers have been added, and tickets are now on sale. You’ll want to get your tickets as soon as possible because the sooner you get them, the cheaper they are, and they’ll be going fast.

There are options for companies that wish to send several different employees over the course of the three days (see Flexi-pass option), as well as student tickets and single day tickets.

Flash on the Beach has offered a brilliant atmosphere and eclectic collection of speakers in the past, focusing on Flash Platform topics, but throwing into the mix anything new and exciting such as iPhone development.

Head over to the website to get yours.

I’ve just migrated from an old MacBook Pro to a new one using Apple’s Migration Assistant. I then thought it’d be a great idea to perform some manual cleanup and accidentally deleted a keychain (in KeyChain Access) which was used by an AIR app I am currently developing.

After doing this I started getting the following error when running my app, as soon as it accessed EncryptedLocalStore:

Error: general internal error
at flash.data::EncryptedLocalStore$/processErrorCode()
at flash.data::EncryptedLocalStore$/getItem()

To prevent this error you just need to delete the relevant folders in:

~/Library/Application Support/Adobe/AIR/ELS/

Where ~ represents your user folder. I’m not sure what the relevant folder is on Windows, probably something similar involving the user’s Application Data folder, but if someone knows for sure please feel free to paste in the comments.

Just a very small post here because I had trouble finding a solution myself. Users of OpenOffice for the Mac may experience odd-looking bullet point characters when opening and saving MS Word .doc files. The character looks like a W inside a box.

Anyway, the problem is due to MS Office not encoding the character correctly when saving the file, but the temporary solution is to use OpenOffice’s Font Replacement feature (see Preferences), to replace “Symbol” with “OpenSymbol”.

Let’s hope there’s some resolution in future, my guess is that the open document formats will just see this issue disappear in time. Here’s a thread that explains the problem, and the solution, in more depth:

http://user.services.openoffice.org/en/forum/viewtopic.php?f=17&t=10846

This post describes how to filter data for use with any component that displays hierarchical data, such as the Tree, AdvancedDataGrid, or your own custom component. For the purpose of the post I’ll just consider the Tree, but the same technique applies to the others.

Background

Suppose I have constructed a “Library” of Folder and Leaf nodes and I want to display that in a Tree. Each Folder node has an ArrayCollection called “children” which contains any child Folders and/or Leaf nodes.

So our classes may resemble something like this (I’ve kept things extremely simple for illustration purposes):

Console games, popular. Flash (browser) games, popular. Combining the two, winning combination.

Flash games have made the leap to consoles several times, from full on ports like Alien Hominid, to Xbox live arcade titles, to Wii browser games. But one idea from Rockstar (creators of GTA), sees gamers laundering money and unlocking stuff for their Nintendo DS copy of GTA: Chinatown Wars.

Another sign of convergence perhaps, where data and services related to a product are made available remotely, or even in the Cloud. Ultimately for Rockstar it means more player time in the GTA universe when their customers are not able to be on their consoles, or perhaps simply a change of scenery.

I’m pretty sure there are other games that have done similar crossovers, but not to this extent. The crossover need not be from virtual to virtual as trading card-based video games have shown. But Flash is becoming such a good tool for creating connected games it’d be easy to say we’ll see more of this sort of partnership in future, perhaps the balance will also tilt in the other direction as the concept of a games console runs its course or evolves* and the power of these “web technologies” really blur the lines.

Link to the article at Develop Mag.

(*I always think back to video game arcades when I think about the future of gaming consoles. In Japan I hear they still have cutting edge games in arcades. In England this has not been true since the release of the Playstation. The games you find in the majority of arcades for £1 a play are Sega Rally 2, House of the Dead, fruit machines and other golden oldies.

There are a few arcades here and there with new versions of Time Crisis and such, but the majority of games have the telltale green magnetic interference and fuzz on their bulky old screens that accompanies age. The arcade was killed by the balance between fun, cost, quality and complexity. Arcade games may have had marginally superior fun and quality, but the cost can make you settle for something else and the complexity of modern games made you weary to waste money just to learn how to play – “attract mode” FAIL. The future of gaming consoles will be killed by an equally ruthless brute-force approach in the guise of convergence and the web.)

Today I had a bit of a nightmare with regards to loading SWFs into AIR. Specifically, I am loading my SWFs from somewhere inside app-storage://, and those SWFs use Flash CS4 UI components. These components extend UIComponent which accesses the stage object. When you attempt to load and add this child SWF to the display list of your AIR app, it generates a SecurityErrorEvent which stops things, dead.

The AIR app owns the stage object, there is only one Stage instance, and depending on what security sandbox the content SWF is loaded into, the child SWF is not allowed access to that stage because it could run amok.

The problem is, when you load a SWF file in AIR, it’ll be run in one of 5 security sandboxes, you can trace Security.sandboxType to see which. These range from the full-access “application” sandbox when loading from the un-modifiable app:// directory, to “local-with-file/network” when loading from app-storage://, to the “remote” sandbox when loading from a server. The latter allows you to use Security.allowDomain() and cross-domain policy files to exert some control as you would in web-based Flash. I won’t go into the exact details of all 5 types here, Adobe have a good article on the sandboxes here.

Either way, I needed to load SWFs from app-storage:// as this is where my application downloads content to, and this content may refer to stage, simply by using Flash CS4 UI Components. Unfortunately there doesn’t seem to be a way to use Loader/SWFLoader/Image to load a SWF from this directory and give it the relevant trust; no amount of tweaking LoaderContexts or ApplicationDomains seemed to allow this. The problem is well documented online, but the solution was hard to come by.

It turns out that you can use a URLLoader to load the raw binary data for a SWF, and then use Loader.loadBytes() or SWFLoader.load(bytes) to bypass this restriction. Word of warning: this is NOT recommended unless you have full control over where your SWFs are coming from, you are effectively allowing arbitrary code to be run within your application with full access to the file system etc.

Below I show a code snippet that illustrates the main points, I’m missing out the rest of the class where I define the members, import classes etc as that’s probably quite obvious.


public function TestLoadBytes()
{
  urlLoader = new URLLoader();
  urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
  urlLoader.addEventListener(Event.COMPLETE, urlLoaderCompleteHandler, false, 0, true);
  urlLoader.addEventListener(IOErrorEvent.IO_ERROR, urlLoaderIOErrorHandler, false, 0, true);
  urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, urlLoaderHttpStatusHandler, false, 0, true);
  urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, urlLoaderSecurityErrorHandler, false, 0, true);
			
  swfLoader = new Loader();
  swfLoader.contentLoaderInfo.addEventListener(Event.INIT, animLoadCompleteHandler, false, 0, true);

  urlLoader.load(new URLRequest("app-storage://path/to/file.swf"));
}

protected function urlLoaderCompleteHandler(event:Event):void
{
  var lc:LoaderContext = new LoaderContext(false, null);
  lc.allowLoadBytesCodeExecution = true;
			
  swfLoader.loadBytes(urlLoader.data, lc);
}

You may notice here I’m also setting “allowLoadBytesCodeExecution” on the LoaderContext for the URLLoader. This is to enable ActionScript execution in the loaded SWF. Again, I should emphasise the warning, but the only other workaround I’m aware of is to use a HTMLControl to display your loaded SWF which allows you to specify a sandbox and also gives that SWF its own Stage, but I couldn’t face running a load of HTMLControls that for the sake of getting stage access in a child SWF.

If you don’t have 100% control over the SWFs you are loading you can put in place validation checks and measures to increase security. There’s a good discussion of this in the comments over at Ethan Malasky’s blog.

So far I haven’t mentioned how to communicate with our newly loaded SWFs… this is where AIR differs from the web Flash Player. The LoaderInfo class gains a “sharedEvents” EventDispatcher instance, which can be used to dispatch events between the two sandboxes. There’s also a mechanism to call functions between the two (similar to LocalConnection), that can be found in LoaderInfo.parentSandboxBridge and LoaderInfo.childSandboxBridge properties respectively.

Again the docs provide a good rundown, even though they are geared towards using the JavaScript/HTML techniques, the classes and techniques remain the same for AS3/Flash. But here’s a quick sample on how to listen to events using the sharedEvents dispatcher object.

In the parent SWF we listen to the Event.COMPLETE event for a SWFLoader instance:


protected function swfLoaderCompleteHandler(event:Event):void
{
  swfLoader.contentLoaderInfo.sharedEvents.addEventListener(MyEvent.SOME_EVENT, someEventHandler, false, 0, true);			
}

In the SWF being loaded, we dispatch events in a similar way:


function someClickHandler(event:MouseEvent):void
{
  loaderInfo.sharedEvents.dispatchEvent(new MyEvent(MyEvent.SOME_EVENT, "SomeParam", someFuncRef, true));
}

I haven’t covered the use of the parent/childSandbox bridge objects which can be used to directly expose and call methods because you can achieve much the same using this sharedEvents approach in a more decoupled way. For example the Event you are dispatching can contain a “callback” function reference that the parent SWF can call when an asyncronous operation has completed.

I rarely blog about gaming, probably because I rarely game, but occasionally something is so extraordinary it grabs my attention.

I caught a video over at Offworld that demonstrates a new real-time strategy game. The twist is that you can both view and interact with the events in the past, present and future (interacting in the past costing a new type of resource).

Here’s the video, it may appear confusing at first but he is demonstrating advanced tactics. This shows the player being attacked in the past by an opponent who is changing history.

Maybe a sensational headline, but it’s no secret in previous posts I have said that I’d “bet the farm” on subscription based services completely overthrowing traditional media consumption in the next few years so this service has really caught my attention.

One of the earliest mainstream examples of this kind of unlimited subscription media probably being Nokia Comes with Music, some years ago now. Well, music is one thing, and video took a little longer, but Netflix, XBox and AppleTV show that’s well and truly “solved”, but what about gaming? Gaming of course relies entirely on reaction times, and on modern consoles runs in higher resolutions than even movies.

Yesterday, to much excitement, Microsoft released Silverlight 3 beta, and gave a run-down on the new features at the MIX09 conference. It has been a very long time since I first looked at Silverlight (here’s my post on a pre 1.0 early build I got to use over in Redmond), and I’ve used both Silverlight and WPF since (which will eventually be two in the same IMHO), one app for the BBC was demo’d at the MIX07 keynote, so I’m fairly familiar with the offering and how it compares.

Just to give a run-down of the key features we’ve seen announced, I’m adding comparisons to Flash features: