Archive for the 'Devices' Category

Nokia N800 + Flash Player = Perfect Video Blogging tool, or “Adobe should make implementing proper web cam support in the Linux Flash Player part of its mobile strategy”

Video Blogging on the N800 with Flash - should exist

Linux is an operating system that's used mainly by hardcore geeks who think in binary and don't mind spending hours compiling their own device drivers. Oh wait, sorry, the year is 2008, not 1998. Scratch that, today, Linux is the operating system that came pre-installed on my easy-to-use Asus Eee PC and my flashy little Nokia N800 Internet tablet.

Both of those devices, by the way, are excellent candidates for my dream video blogging machine. The N800 more so than the Eee PC.

Both the Eee PC (at least the 4GB model I have) and the N800 have internal web cams and WiFi. They're both tiny enough to carry around easily (far more so than a full-size laptop like my MacBook Pro), and, in the case of the N800, the camera actually swivels around so you can shoot your subject while looking at the screen.

And they both support Flash Player 9.

So, budding video bloggers, grab your N800s, connect to Seesmic, and start vlogging away, live, from anywhere with a WiFi Internet connection.

Not so fast. They're a slight niggle. The web cam on neither the N800 nor the Eee PC works with the Flash 9 Player for Linux. (And, reportedly, the same holds true for the newer N810.) In fact, according to reports on the Net, you would be hard-pressed to find a web cam that does work well with Flash Player 9 on Linux.

The problem is that Flash Player 9 on Linux supports an outdated interface (Video4Linux 1) for connecting to web cams; leaving the built-in web cam in many newer devices, including Nokia N800 and the Asus Eee PC, unsupported. What Adobe must do is add Video4Linux 2 support to Flash Player on Linux.

As video blogging becomes mainstream, I can't help but feel that Adobe is about to miss another chance in the mobile arena by not implementing proper web cam support in the Flash Player for devices like the N800 that run Linux.

If I was Nokia, I would be talking to Adobe right now about what we can do to realize web cam support for Flash Player 9 on Linux as soon as possible and start pushing the N800 and N810 as the perfect live video blogging tools.

If I was Loic Le Meur, I would be emailing Adobe about how important this feature would be for my popular Flex-based RIA, Seesmic. I would probably also be on the phone to Nokia too to have Seesmic included as a standard application link in the N800 series OS.

And, finally, if I was calling the shots at Adobe, I would be redoubling my efforts to get proper web cam support into the Linux version of the Flash Player as part of my mobile strategy. I would make it a priority to support and encourage the use of Flash-and-WiFi-enabled Linux devices with web cams, coupled with Flash applications like Yahoo! Live and Seesmic, as low-cost live video blogging and real-time web news-gathering and reporting tools.

Devices like the Nokia N800, N810, and Asus Eee PC are already on the market and in the hands of content creators. With an update to Flash Player 9 on Linux that implements proper web cam support, we have the chance to give them a whole new use case and make the Flash the de-facto standard platform for mobile video blogging.

My kind of bug

Bug

I'm definitely not a hardware hacker. Pulling apart the innards of a Chumby does not excite me. I don't read Make. But BUG by Bug Labs looks like something I'd love to get my hands on.

CNET sums up the BUG perfectly as "The Lego of Gadgets".

You have a base BUG (called -- surprise, surprise -- BUGbase) that is essentially a tiny ARM-based computer. To this, you plug in hardware modules. The modules plug in like Lego bricks. There's no soldering or messing with wires (i.e., all that stuff that hardware hackers love and I don't get!) Available modules include GPS, Digital Camera/Video, a touch-sensitive color LCD screen (what, no multi-touch? Apple you have truly spoiled me!) There's also an accelerometer and motion sensor module. The BUGbase and available modules are currently on sale for early adopters.

The early-adopter BUGbase differs from the version that will ship later in the year in that it does not have WiFi and its UI features a joystick-based navigation scheme as opposed to a panel-based button system.

You program the BUG using Java and the software stack is completely open source.

How cool would it be to have Flash on this thing? Very, very cool. Can you imagine creating your own device and then creating the UI via Flash? And having it interface with the various modules natively (e.g., camera/video support, GPS/motion sensor/accelerometer access via a socket server, etc.) Now that would truly rock!

Via Mashable.

SWX Jobs

Intercasting Corp swx job

Intercasting Corporation has a job opening for a Flash/Flash Lite Handset Developer and they list knowledge of SWX as a nice-to-have skill on the job description. Another OSFlash project, Red5, is also listed in the same section.

It's really cool to see development houses adopting SWX for Flash and Flash Lite development. If you have any relevant job openings that you want to advertise, please feel free to contact me via the comments or send an email to the SWX mailing list.

There's also a Flash and Flex job board on OSFlash if you want to reach a more targeted audience of open source Flash developers.

Also, if you're making things with SWX and want to get exposure for them, feel free to leave a link at the SWX Showcase and I will feature them there.

Thanks go to Alex Tur of Sonopia for bringing this to my attention. Thanks, man!

SWX PHP and SWX AS now support Flash 6+

I just tested the SWX SWFs being generated by the SWX PHP gateway and I'm happy to report that they work perfectly well in Flash 6 projects. This means that you can use SWX RPC on the following platforms in addition to the existing ones:

  • Sony PSP with Firmware 2.7 or greater.
  • Nokia N770 Internet Tablet.
  • Microsoft Pocket PC 2003 devices.

If you want to use SWX AS (the SWX ActionScript libraries) in Flash 6 projects ahead of the upcoming SWX PHP RC1 release, please check out the latest version from SVN (http://svn1.cvsdude.com/osflash/swx/trunk/).

I want to thank Hayden Porter for emailing me to ask about Flash 6 support in SWX and for providing the list of devices that currently run Flash 6.

What is SWX, how does it work, and where is it going?

I do some of my best thinking (and singing) in the shower. So it's no surprise that this morning, while in the shower, I decided to review my plans and roadmap for SWX. Here's a direct-from-the-shower look at what SWX is, how it works (with a few examples to get you up and running), and roadmap of where SWX is heading.

Some of the contents of this post will be familiar to my friends at Yahoo! UK, where I presented SWX earlier this month. (Thank you guys for your amazing support, it means a lot!)

Definitions

Let's start at the beginning with some definitions. When I first embarked on SWX, the technology and implementation were one and the same. Several months on, SWX has matured and simply bundling everything in the SWX ecosystem as "SWX" is not sufficient. To that end, here are some definitions of SWX-related concepts to start us off with a common vocabulary for talking about SWX.

  • SWX: Native data format for Flash. It is a subset of the SWF format. SWX SWFs are regular SWF files that are used to store just data.
  • SWX RPC: RPC protocol encoded in SWX. Allows you to call methods on server-side classes and get the results in SWX format.
  • SWX PHP: SWX RPC implementation in PHP. SWX PHP is currently the only implementation of SWX RPC but there will be Python, Ruby, J2EE, .Net, etc. implementations in the future.
  • SWX Tools: The SWX Service Explorer & SWX Data Analyzer. These tools come bundled with SWX PHP and will work with any future implementations of SWX RPC.
  • SWX AS: A high-level ActionScript library that handles 
the client-side queuing and execution of SWX RPC calls. You don't have to use the ActionScript library to work with SWX RPC as SWX is native to Flash but the library does provide you with useful functionality such as cross-domain access, queueing of data calls, etc.
  • SWX APIs: APIs for Flickr, Twitter, etc. I am as excited about the SWX APIs as I am about the SWX data format and SWX RPC as they provide Flash developers with a very easy way to create mashups. In fact, if you hit the Public SWX RPC gateway (see below) at swxformat.org, you can use these APIs with ActionScript alone (no server-side programming is necessary.)
  • Public SWX RPC gateway: Open SWX RPC endpoint. The Public SWX RPC Gateway
is at http://swxformat.org/php/swx.php. You can use the public SWX
APIs from this gateway in your own applications without having to
write any server-side code whatsoever.

Supported platforms and technologies

Swx Supported Platforms

You can create and load SWX SWF files with any version of Flash (5+) as they are simply SWF files. As far as manually creating SWX files go, SWX is supported on Flash 5+.

SWX PHP, the current SWX RPC implementation that I'm working on, creates SWX files that are compatible with Flash 7+ Flash 6+, Flash Lite 2.0 and Flash Lite 2.1. Currently, SWX PHP does not support Flash 9/AVM2 but it will eventually do so.

SWX AS, the SWX ActionScript library, compiles on Flash 7+ Flash 6+ and MTASC.

You can use SWX PHP currently to create applications that run on mobile phones (Flash Lite 2.0/2.1), the Nintenso Wii, Sony PS3, and devices like the Nokia N800 internet tablet and the Chumby.

You can also wrap SWX-based applications to create desktop versions using Adobe Air.

SWX (SWF Data Format)

SWX is the native data format for Flash. Data is stored as SWF bytecode (you can't get more native than that on the Flash Platform) that is interpreted by the Flash Player. The SWX format is a subset of the SWF format (just like JSON is a subset of JavaScript).

SWX is open. I am in the process of writing an Internet Draft (I-D) for SWX which I hope will become an informational RFC.

You loadMovie() SWX data files and they are ready to use the moment they are loaded. You don't need to deserialize or massage the data in any way before using it as it is stored in native Flash objects.

Why do we need a new data format?

When I first announced SWX, Patrick Mineault questioned whether SWX was reinventing the wheel. Why, he asked, do we need SWX when there is AMFPHP? (AMFPHP is a PHP implementation of a Flash Remoting gateway).

To start with, comparing SWX and AMFPHP is like comparing apples and oranges. As I stated earlier, SWX is a new data format for Flash and SWX RPC is a remote procedure call protocol encoded in SWX. As such, we can compare SWX to AMF (the data format) and SWX RCP to Flash Remoting (the RPC protocol) and SWX PHP (my PHP implementation of SWX RPC) to AMF PHP.

So the real question becomes, does the Flash Platform need a new data format and a new RPC protocol? I believe it does and here are some reasons why:

  • Existing formats are non-native, complicated, require parsing and/or writing plumbing code e.g., XML, variable-encoded strings (LoadVars, loadVariables), Flash Remoting, etc.
  • SWX files have low processor overhead when parsed by the Flash Player as they are native (SWF bytecode)
  • SWX RPC is the only RPC solution for Flash Lite 2.0 and 2.1 (and thus for mobile Flash applications). Flash Remoting does not work with Flash Lite.
  • Most important: SWX, being native, has inherent advantages such as cross-platform data exchange (via allowDomain support for SWF files), simplicity (no ActionScript library is necessary to use it), etc.

It's my first belief that every platform can benefit from a native data format that does not require parsing. The main advantage of SWX over other data formats and of SWX RPC over other RPC solutions is ease of use. I hope that this ease of use will spur a wealth of development of data-driven applications and mashups on the Flash Platform by developers who may traditionally have shied away from creating such applications because it was just too darn hard to do so.

SWX RPC

SWX RPC is a remote procedure call protocol encoded in SWX format. You use it to call methods on server-side classes (called services in SWX RPC) and get the results returned to you in SWX format.

SWX RPC is open. I am in the process of writing an Internet Draft (I-D) for SWX RPC which I hope will become an informational RFC.

SWX RCP is stateless, lightweight, and uses HTTP as the transfer protocol.

A typical SWX RPC call involves parameters sent from Flash to the SWX RPC endpoint (gateway) in JSON format. These consist of serviceClass, method, and args parameters that define the method on the service class that you want to call on the back-end and the arguments that you want to send to that method. The resulting data is returned to Flash in the result property.

SWX PHP

SWX PHP is a SWX RPC implementation in PHP. It is open source.

SWX PHP is written in pure PHP. It doesn't require any extensions and runs under both PHP 4 and 5. (As such, it runs without problems even on shared hosting accounts.)

SWX PHP has a SWX RPC endpoint (gateway) and an assembler that creates and returns SWX files. Your service classes contain business logic only.

SWX PHP comes with service classes (APIs) for Flickr, Twitter, Ten Word Review, Nabaztag, etc. There is a publicly accessible instance of SWX PHP running on swxformat.org at http://swxformat.org/php/swx.php. You can access these APIs from this public gateway without hosting your own instance of SWX PHP if you want to build mashups using just these APIs.

SWX PHP uses Amfphp as a library and this means that you can also hit SWX PHP services via Flash Remoting, JSON and XML-RPC. (In other words, you're not locked into using SWX RPC and you can switch easily between these various technologies if you want to.)

SWX PHP comes with a plain vanilla installer (unzip it into your web folder on the server and go) and as a MAMP Bundle (everything you need to get up and running with SWX PHP on OS X). I am planning on creating Windows and Linux bundles as well in the future. In the meanwhile, I recommend using WAMP on Windows and XAMMP on Linux is you want to quickly get up and running with a server (Apache + PHP, etc.) on your development machine.

SWX PHP adheres to SWX’s core philosophy of Systemwide Simplicity.

Systemwide simplicity

A system is only as simple as its most complicated part. It's not enough to just simplify individual components and processes, you must also simplify the relationships and interactions between components and sub-processes. Systemwide Simplicity takes a wider approach to simplicity that involves understanding and supporting the entire user experience.

It is thus my aim to make it as easy as humanly possible for Flash developers to start creating data-driven Flash applications from the moment they arrive on the SWX homepage to the moment they first get data into Flash using SWX RPC.

How simple is SWX? Moo card example

SWX is so simple that instructions for getting data into Flash using it easily fit on to a Moo card. (In fact, I've just ordered two sets of Moo cards with just this example on them -- ask me for one if you see me around!)

To get a list of the most recent 100 photos from Flickr into Flash, do the following:

  • Open up the SWX Data Analyzer
  • In Flash, create a new FLA and create a movie clip on the Stage. Give it the instance name loader.
  • Write the following code on to the frame that the loader movie clip is on:
loader.serviceClass = "Flickr";
loader.method = "swxPhotosGetRecent";
loader.debug = true;
 
loader.loadMovie("http://swxformat.org/php/swx.php", "GET");

That’s it! Test your movie and look in the SWX Data Analyzer to see the results being loaded in to Flash from Flickr. That’s how simple SWX is.

If you want to display the results from within Flash, create a long, single-line dynamic text field on stage and give it the instance name status. Add the following code to the timeline:

function onEnterFrame()
{
    status.text = loader.result.photo[0].src;
}

Initially, the status text field will display undefined until the data is loaded and then it will display the URL of the first photo from the list of recent photos that is loaded from Flickr. Notice how you can access the results as native Flash objects the moment they’re loaded. No deserialization or massaging of the data is necessary!

Read the next section to see a better way of handing results using SWX AS and the SWX Class in ActionScript.

Building a complete web application (back-end and front-end) with SWX PHP

In the next ten minutes you are going to learn everything there is to know about exactly how SWX PHP works by building a very simple, but complete, data-driven Flash application. You will be using Flash to create the client and PHP (with SWX) for the server.

Installing SWX PHP

If you haven’t done so already, download and install SWX PHP on to your computer. Before installing SWX PHP, you will need to have a web server running PHP on the machine you’re installing it on.

If you’re on a Mac, running OS X, download and install the SWX PHP MAMP Bundle. This will have you up and running with everything you need using a simple installer.

If you’re on Windows, I suggest installing WAMP and, on Linux, XAMMP. Both of these are single-click installers that provide you with a turnkey development environment with a web server (Apache) and PHP.

Once you’ve installed a web server and PHP, just download SWX PHP and unzip it into your web root. Start your web server and hit the web root in your browser to access the SWX PHP Start Page.

Swxphp Start Page


Getting Started

The application you’re going to build is a simple calculator that uses a server-side method to add two numbers together.

To start, you're going to create a PHP service class. In SWX you place service classes under the php/services folder.

SWX Service Explorer

To see what services are already in the services folder, you can use the SWX Service Explorer that comes with SWX PHP. Open that now and you will see that there are several services there already.

Swx Service Explorer

Creating the Calculator service class in PHP

Create a new file using your text editor of choice under php/services/ and call it Calculator.php.

Add the following code to Calculator.php and save the file:

 
<?php
    class Calculator
    {
        function addNumbers($n1, $n2)
        {
            return $n1 + $n2;
        }
    }
?>

This is a very simple server-side service class that has a single method called addNumbers(). This method takes two numbers as arguments and returns their sum.

At this point, it would be nice if you could test the server-side method you just created without having to create a Flash client. SWX Service Explorer lets you do just that.
Testing server-side methods with the SWX Service Explorer

Return to the SWX Service Explorer (or open it if you didn't earlier) and you will see the Calculator class you just created. Click on it and you will see the addNumbers() method that you just created. Enter two numbers in the $n1 and $n2 fields and press the call button to test out the method. You should see the sum returned in the results area.

Your server-side service method is working correctly. Now let’s call it from Flash.

  1. Open up Flash and create a new FLA (ActionScript 2). You can set the publish setting to Flash 7 or 8.
  2. On Frame 1 of the new FLA, create a movie clip instance and give it the instance name dataHolder.
  3. Create a new layer and call it Actions. On the Actions layer, add the following code:
dataHolder.serviceClass = "Calculator";
dataHolder.method = "addNumbers";
dataHolder.args = "[35, 7]";
dataHolder.debug = true;
 
dataHolder.loadMovie("http://localhost:8888/php/swx.php", "GET");

That's it! That's all the code you need to call the addNumbers method on the Calculator service class in PHP and pass it the numbers 35 and 7 as arguments. The loadMovie calls the SWX gateway and passes to it any of the properties you set on your movie clip. In this case, since we are sending a small number of arguments, we use the GET HTTP encoding method. We could just as easily have used POST.

SWX Data Analyzer

Before testing the movie, open the SWX Data Analyzer in a separate browser window.

Swx Data Analyzer

SWX Data Analyzer is a debugging tool that shows you the SWX data that arrives inside your Flash movie.

To make SWX data that loads into the Flash player appear in Analyzer, you turn debug mode on. That's what the line dataHolder.debug = true does.

Now, test your movie and then look in the Analyzer. If all went well, you should see the number 42.

Accessing the result property

That's great, but now let's display that result in Flash. You're going to implement a quick hack to get it working and we can evolve the application later to improve it.

Add a TextField instance to the Stage and give it the instance name status.

Next, create an onEnterFrame handler that prints out the value of the result property of the dataHolder movie clip into the status text field.

The complete script at this point is shown below:

dataHolder.serviceClass = "Calculator";
dataHolder.method = "addNumbers";
dataHolder.args = "[35, 7]";
dataHolder.debug = true;
 
dataHolder.loadMovie("http://localhost:8888/php/swx.php", "GET");
 
<strong>function onEnterFrame()
{
    status.text = dataHolder.result;
}</strong>

Test the movie and you should see the number 42 appear in the status text field.

Now stop for a moment and take a deep breath: You now know exactly how SWX RPC works!

You didn't import any classes, you aren't using an API, you didn't include any external code whatsoever. SWX is completely native to the Flash platform and, if you want to, you can make use of it by using only built-in Flash features like you did here.

Compare this to other technologies like Flash Remoting. Do you actually know exactly how Flash Remoting works? There are numerous classes, lots of code, etc. There's some magic involved that you don't really understand. Not so with SWX RPC. With SWX RPC, your data arrives in native Flash format.

It's important for a technology to be so simple that you can actually conceptualize it completely. However, that doesn't mean that the above method is the way you'd want to use SWX PHP on a daily basis.

For one thing, take a look at how you set the arguments. It's a string. In fact, what you did was serialize the arguments you're sending in JSON format. It's not confusing or difficult to this by hand if you are sending simple arguments like two numbers but what if you wanted to send an array of complex objects over? It would get tiresome and impractical very quickly.

The example you just created uses the No API method. In other words, you used pure Flash. No additional classes.

However, to make your life easier, you may want to use just a little API. Specifically, a method to serialize your arguments into JSON format for you would be nice. The SWX AS minimal API provides just such a method. Modify the code sample so that it matches the listing below:

<strong>import org.swxformat.SWX;</strong>
 
dataHolder.serviceClass = "Calculator";
dataHolder.method = "addNumbers";
dataHolder.args = <strong>[35, 7]</strong>;
dataHolder.debug = true;
 
<strong>SWX.prepare(dataHolder);</strong>
 
dataHolder.loadMovie("http://localhost:8888/php/swx.php", "GET");
 
function onEnterFrame()
{
    status.text = dataHolder.result;
}

Notice the lines that have been added and the line that had changed (in boldface). The prepare() static method of the SWX class simply serializes your arguments into JSON format for you. Notice that the args property in your dataHolder is no longer a string but an ActionScript array with two numbers inside it.

This is definitely far better than manually serializing your arguments by hand but it's still not ideal, is it? For one thing, that onEnterFrame function we're using is not a good practice. It would be really nice if we could have an event handler called when the data arrives instead of polling for it. The SWX AS Full API provides that functionality (and a few more).

Modify the code listing so that it matches the one below:

import org.swxformat.SWX;
 
<strong>var swx:SWX = new SWX();
swx.gateway = "http://localhost:8888/php/swx.php";
swx.encoding = "GET";
swx.debug = true;
 
var callParameters:Object =
{
    serviceClass: "Calculator",
    method: "addNumbers",
    args: [35, 7],
    result: [this, resultHandler]
}
 
swx.call(callParameters);
 
function resultHandler(event:Object)
{
    status.text = event.result;
}</strong>

When you run the above example, you should again see 42 in the status text field. Let's look at what has changed.

When using the SWX AS Full API, you actually instantiate the SWX class and set some properties there (such as the gateway URL, encoding method and whether you want debug information for calls).

Instead of putting call-related parameters directly into a movie clip (you can delete the dataHolder movie clip now as you aren't using it any more), you create a callParameters object and specify the serviceClass, method, and args properties there. But you can do more, you can also specify a result handler that will get called once the data has loaded.

The result handler receives an event object as an argument. That event object has a result property that points to the loaded data.

The SWX AS Full API doesn't stop there. You can also specify a timeout handler to handle calls that take too long.

Modify the listing so that it matches the one below:

import org.swxformat.SWX;
 
var swx:SWX = new SWX();
swx.gateway = "http://localhost:8888/php/swx.php";
swx.encoding = "GET";
swx.debug = true;
<strong>swx.timeout = 2;</strong> // seconds
 
var callParameters:Object =
{
    serviceClass: "Calculator",
    method: "addNumbers",
    args: [35, 7],
    result: [this, resultHandler],
    <strong>timeout: [this, timeoutHandler]</strong>
}
 
swx.call(callParameters);
 
function resultHandler(event:Object)
{
    status.text = event.result;
}
 
<strong>function timeoutHandler()
{
    status.text = "Call timed out!";
}</strong>
 

The default timeout duration is 30 seconds but you can override that, as shown here.

In order to make the call actually time out, modify the Calculator class in PHP too to make it sleep for 10 seconds before returning the result. The Calculator class should match the one in the listing below:

&lt;?php
class Calculator
{
    function addNumbers($n1, $n2)
    {
        <strong>sleep(10);</strong> // Make the call time out!
        return $n1 + $n2;
    }
}
?&gt;

Now test your Flash movie and, after two seconds, you should see the SWX call time out. Timed-out calls are cancelled and will not trigger the result handler at any point in the future.

Finally, there is also a fault handler that you can use in the same way. To test it out, modify the ActionScript listing so that it matches the one below:

import org.swxformat.SWX;
 
var swx:SWX = new SWX();
swx.gateway = "http://localhost:8888/php/swx.php";
swx.encoding = "GET";
swx.debug = true;
swx.timeout = 2; // seconds
 
var callParameters:Object =
{
    serviceClass: "Calculator",
    method: "addNumbers",
    args: [35, 7],
    result: [this, resultHandler],
    timeout: [this, timeoutHandler],
    <strong>fault: [this, faultHandler]</strong>
}
 
swx.call(callParameters);
 
function resultHandler(event:Object)
{
    status.text = event.result;
}
 
function timeoutHandler()
{
    status.text = "Call timed out!";
}
 
<strong>function faultHandler(event:Object)
{
    status.text = event.fault.message;
}</strong>

And modify your class so that it generates an error:

&lt;?php
    class Calculator
    {
        function addNumbers($n1, $n2)
        {
            <strong>return $n3;</strong> // $n3 does not exist!
        }
    }
?>&gt;

Test your FLA and you should get something along the lines of Error 8: Undefined variable: n3 in /htdocs/swx/trunk/php/services/Calculator.php, line 7 in the status text field in Flash.

The fault handler also returns API-specific fault codes (e.g., Flickr API error codes) back to Flash.

And that, in a nutshell, is the SWX AS Full API.

There's more to SWX that we haven't covered in this introductory article such as the LoadManager and ExternalAsset classes that the SWX AS Full API uses internally to queue and load SWX SWFs but you can find out more information about these in more advanced tutorials to be released soon (they are useful when you want to load your own external assets like SWFs, JPGs, etc.)

Beyond making your own service classes, you can also use the existing service classes in SWX to access public APIs like the Twitter API and Flickr API. In fact, why don’t you play around with the Twitter and Flickr APIs now, using the PHP Service Browser to discover how they work? You can modify the examples above to get data from any of those APIs as easily as you have done here.

There is also a screencast of this example that you can watch online.

SWX and Flash Lite (mobile applications)

SWX and SWX RPC work in Flash Lite 2.0 and 2.1! In fact, due to its low processor overhead and native support in Flash, SWX is the ideal data format for mobile applications with Flash Lite.

Check out the MiniFlickr sample application that comes with SWX PHP for an example of how to build data-driven Flash Lite applications using SWX.

Keep in mind that, due to a bug in Flash Lite, you cannot make POST requests in a loadMovie call. Instead, you must make GET requests when using SWX RPC with Flash Lite. For more information on this, see the Mobile Limitations section, below.

The MiniFlickr application makes use of the ExternalAsset and LoadManager classes that come with SWX AS to queue all load requests (data and assets such as images). This is essential in mobile development as most handsets will fail if you try to load two things at once. The SWX AS Full API handles the queueing of requests for you and gives you a general purpose load queue that you can use in your own applications. Make sure you study the MiniFlickr sample if you want to create Flash Lite applications using SWX PHP.

Swx Mobile Device Central

SWX and SWX RPC advantages for mobile development

SWX RPC is the only RPC solution for Flash Lite and, beyond that, it works really well and is simple to use. Here is a summary of some of the advantages of the SWX data format and SWX RPC for Flash Lite development:

  • Native; data is ready to use the moment it loads as native ActionScript objects.
  • No processor-intensive parsing, etc.
  • No plumbing code for deserializing requests.
  • Public gateway and APIs for mobile mashups.
  • Only RPC solution for Flash Lite.
  • Easy to understand and use.

SWX Flickr API

As of the upcoming SWX PHP Release Candidate 1, a full implementation of the Flickr API is included in SWX PHP.

You can start playing with the SWX Flickr API right now, using the Public SWX RPC gateway. Try the methods out online using the SWX Service Explorer.

  • Implements the full Flickr API, current as of August 1, 2007.
  • Liberal open source license (MIT).
  • Provides photo upload feature.
  • Actively maintained and updated.
  • Simplest way for Flash developers to work with Flickr.

Roadmap

So where is SWX, SWX RPC, and SWX PHP going?

I realized today that I was being overly ambitious with my plans for version 1 of SWX PHP.

For one thing, I had considered getting the Flash 9/AVM2 version of SWX PHP ready in time for version 1 but that involves writing a whole new assembler. I've now decided to leave this for after the 1.0 release so that I can instead concentrate on getting a polished and stable 1.0 release of SWX PHP that includes all the learning materials, screencasts, etc. that you need to get up and running with SWX RPC.

SWX PHP already fills a gaping void in RPC solutions for Flash Lite and getting SWX PHP to version 1.0 is important in getting development houses to adopt SWX PHP for production of Flash Lite applications.

Also, the SWX assembler (the bit that creates the SWX SWF files) in SWX PHP is extremely stable and has been for a while and I want the Flash 9/AVM2 version of it to be as stable when it goes into version 1 but that's not realistically going to happen in the timeframe that I have in mind.

So, instead of working on yet another implementation, I'm going to spend the next few weeks working on the Internet Drafts for SWX and SWX RPC and on documenting the heck out of SWX so that others can create implementations of SWX RPC (in fact, if anyone is interested in undertaking the Flash 9/AVM2 implementation for PHP, please get in touch).

What is important is that eventual Ruby, Python, J2EE, .Net, etc. implementations of SWX RPC are all compatible and that they all adhere to the same philosophy of simplicity. (And thus, for example, do not require extensions, etc. or place other barriers in front of developers.)

So what is the eventual release data of SWX PHP? I'm going to be aiming for the start of September and definitely before FlashForward Boston.

I will be releasing Release Candidate 1 of SWX PHP this week so keep any eye out for that on this blog.

Also expect a number of new screencasts in the coming days, showing you how to work with SWX PHP and the various APIs and how to create mobile applications using SWX PHP.

Come September, I will be embarking on a crazy schedule of conferences, starting with FlashForward Boston to present my session Let's talk about SWX, baby!

The conferences I'll be presenting SWX at include MAX Chicago, FlashForum Conference (Germany), MAX Barcelona, FITC Hollywood, Flash on the Beach (Brighton, UK), and MAX Japan.

I hope I'll get to meet and talk with some of you at these conferences. If you see me, do come up and say hello and ask me for a SWX Moo card and a SWX Moo sticker :)

Nokia N800 Internet Tablet with Flash 9: First impressions

I just received my Nokia N800 Internet Tablet and, after checking with Paul (who just got a N770 himself at a ridiculously low price from Expansys) that it worked, got home and flashed the system software to the latest version that was released this month. The N800 runs Linux and this latest system image comes with Flash 9.

If you're on OS X, there are instructions available on how to upgrade the N800's system image on OS X. Make sure you download the latest N800 system image from here though, since the URL in those instructions is for the N770. (And, you don't have to remove the battery on the N800 to get the information you need to download the upgrade.) I downloaded the latest system image, which, at the time of this post, was called RX-34_2007SE_4.2007.26-8_PR_COMBINED_MR0_ARM.bin. Finally, place the 770Flasher.app and the system image on the root of your hard drive because I believe that the app has a problem with complicated folder names (it didn't work for me when I had 770Flasher.app in my /Applications folder and the system image in my Web Downloads folder.)

So, how does the N800 perform with Flash 9 content?

What can I say? The first thing I tried was the SWX Service Explorer, which is a Flex 2 application. And it ran. I'm floored right now. This is the first time I'm seeing a Flex application run on a device. It's not snappy but it's not unusable either. Wow! No script timeouts or anything. Love it! :)

Next, I went to Papervision3D.org and got the logo but it never went further to display the aquarium (it didn't throw any errors or freeze either). Fair enough, that was a though test.

It's too late and I'm too tired to try anything else out on it tonight but it's so promising. This should be able to handle pretty much any Flash content thrown at it.

Other stuff in brief:

  • Videos on this device rock. We watched the one that comes on it with Paul and were blown away.
  • The screen is amazing. You can view it from any angle, all the way to 180.

One word of warning: The stylus that it came with appears to have scratched the screen. I tested with the backup stylus in the box and that one didn't do it initially but appears to be scratching it now. I may end up sending this unit back and getting another one as the scratches look to be permanent. What a shame. I can't believe they skimped on the stylus (or didn't provide a scratch-resistant surface/scratch protector.) I mean, I've only been playing with it for half an hour.

Update: Ah, just read this:

On a brand new n800, it had towards the bottom left side of the screen, a silver squared tab. I assumed this tab was there to pull out the whole plastic that commonly covers the whole screen and comes from factory, to protect the screen during transportation.

So, I pulled it and suddenly, only the silver tab, came off the screen. This really seemd strange but, I tought, oh well, there was no factory plastic after all, just a little silver tab sticker.... I really didn't notice, until days later, that there was left something that looked like some kind of "screen protector" film.

I noticed that "protective film" since, after a week of normal use, the screen appeared to look scratched.

When I was at Paul's the same thing happened to me. I thought nothing of it. So apparently it's the temporary screen protector that didn't come off that's getting scratched. Whew! :)

I can't wait to play with this baby more in the coming days :)

Flash Lite and Mobile Development

Notes from Dave Yang and Dongyub Lee's session at FITC.

Dave starts off the session.

MGMaps: Grabs maps from Google maps and uses GPS to locate you on your mobile phone.
Streaming video: He's showing us the Slingbox Mobile Player.

He's showing a QR Code example:

  • Firefox extension: tinyurl.com/36evg6
  • Kaywa Reader: http://reader.kaywa.com
  • Kaywa Generator: http://qrcode.kaywa.com
  • Nokia: 83.145.232.112

RFID (inventory tracking, sales info, security, transportation, games). Requires hardware reader/receiver. More expensive than QR Code.

Dongyub takes the stage.

Flashlite works on a range of embedded devices:

  • MP3 players (e.g., iRiver)
  • PMP (portable multimedia player; PMC; MP4 player)
  • Mobile phones
  • PDA
  • Other: Digital setup box, medical devices

He's going to demonstrate several such devices for us:

  • iRiver Clix1 / U10 (Flashlite 1.1, Flash UI)
  • Lupo Carrot Kids (edutainment device for kids; similar to Nintendo DS) - Setup, Contents pack - looks very cool!
  • Samsung M4500 (comes with Flashlite) - Apocket.com, MyUI (a customizable home automation controller UI)
  • Yukyung Viliv P1 (PMP player) - Flash UI, Flash games

Others:

B20, E10, clix2, etc.

UI Trends/timeline:

  • Text UI: Black and white
  • Bitmap symbols - color
  • Animated icons (flip images)
  • 3D rendered images
  • Flash UI - motion graphics with simple shapes

Dave's back on the mike.

Common mobile OS and platforms:

  • Symbian S40/60/90/UIQ
  • Windows Mobile
  • BREW
  • Palm (new Linux platform announced)
  • OSX (upcoming)
  • J2ME
    Opera/Ajax

Phones, etc., but also gaming consoles (Wii, PS3, PSP), Cameras, GPS, dashboard displays, TVs, Chumby, set-top box, iTV, etc. For more see http://adobe.com/mobile/supported_devices/

Flashlite versions:

  • Flashlite 2.1 MMI - latest version
  • Flashlite 3 is coming
  • Flash Player for PocketPC
  • Neo MTEL GUI engine (90% compatible with Flash 7)
  • Digitalaria Mobile Flash (based on Flash 4 -- been around for 7 years or so ago)

Interfacing with the device:

  • FSCommand2: send commands/query host
  • Functions called in the SWF from the host (callbacks for incoming calls, etc.)
  • Use an external files (loadMovie, loadVariables)
  • Key events

Typical project:

  1. Device manufacturer: firmware programming
  2. Designer: graphic design
  3. Device manufacturer: User interface logic, program logic, application dev.

Flashlite project:

  • Project manager: Interface management
  • Flashlite Dev: Graphic design, user interface logic, application dev
  • Device manufacturer: Firmware programming, program logic

Flashlite projects thus save time as the Flash team can work independently from the device manufacturer.

Dongyub is now showing the iRiver Clix2. Comes with Flash standalone player.

Flashlite 2 supports device video (native video format). Video is played on top of Flash. Minimal interactivity. Flashlite 3 supports streaming from FMS.

Symbian:

SWF2Go: Packages SWF, icon, and other content as a .sis installer. S2G-FITC (10% promo code). http:/www.orison.biz/store

Distribution:

Verizon wireless (BREW/USA only): Over-the-air delivery (auto download of Flashlite player)
Symbian:

Resources:

More to come:

  • FlashCast
  • FlashHome
  • Flash Lite 3

FlashForward KeyNote at MacWorld

I took notes during the FlashForward keynote at MacWorld today but couldn't post them since I didn't have WiFi in the room. It was a nice keynote and we got some cool sneak peeks at Flash CS3 and Apollo and a fun presentation on Flash on the Wii by Justin. Here are my notes:

I'm sitting in at the FlashForward keynote at MacWorld. Lynda just gave the opening speech and introduced Mike Downey.

Mike: We will be shipping the full production studio for the Mac, including Premiere, Encore and Sound Booth. (This was announced last week.) On Friday, we announced that we have finished and shipped Flex Builder for the Mac. About a month ago we released Photoshop CS3 in beta on Adobe Labs.

Flash Player Adoption update. Flash Player 9 is projected to reach over 70% penetration in its first six months. In comparison, Flash Player 8 took 9 months to reach over 80% and Flash Player 7 took twelve months to break 70% penetration. Basically, the adoption rate of the Flash Player is accelerating with each player release and continues to do so with Flash Player 9.

What's new in the Flash Player 9? Mike focusses on the new virtual machine with ActionScript 3 support and its performance improvements. AS3 is an ECMAScript implementation that uses the W3C DOM Level 3 event model, E4X (ECMAScript for XML), Regular Expressions and runtime error checking.

Mike is showing some example sites that showcase Flash Player 9. He starts with Kuler, Adobe's own online color utility.

In Flash Player 9.1, Adobe added a fullscreen feature. Mike shows the full screen demos linked to from the Labs Wiki. He demos the full-screen panorama made with Papervision 3D, which of course, you can find on OSFlash.

Flash Video has an unbelievable momentum which has mostly picked up following the release of Flash Player 8. Taking Flash Player 7 as the starting point, use of Flash video has grown 800x in the past three years, with the steepest rise taking place in 2006.

Mobile is another area that Flash has a presence in, especially in Japan. In September 2006, FlashLite was deployed on over 150 million handsets. In the US, in partnership with Qualcomm and Verizon, Adobe can distribute the FlashLite player to handsets over the air.

Flash can Wii

Now Justin Everett-Church takes the stage and he's going to talk about the Nintendo Wii. He is showing the Opera browser for the Wii, which, of course, comes with Flash Player 7. He is showing a mashup he did with Yahoo maps. He mentions the resolution of the browser (800x500) can make it difficult to read things and that he is actually doubling the size of his UI to make it more legible on the screen. Good tip.

Now he's showing YouTube and playing back some YouTube video.

Next, he is showing a 3D pool game from TeaGames to show the performance of the player. Looks good.

Now he's showing a game he created a while back called Insane in the Membrance. He loaded a SWF directly. It's not an 800x500 SWF but since it is vector, it scales. The game runs really well. This mirrors my own experience with the Flash Player on the Wii, which is that the player performance is very good.

Mike's returned to the stage now. He's mentioning that the Flash Player is also available on other game consoles. Mike Chambers is now taking the stage to show Flex and Apollo. To recap, Apollo is a cross-operating system runtime that allows developers to leverage their existing web development skills (Flash, Flex, HTML, Ajax) to build and deploy desktop RIAs.

He's demoing Ascension, an Apollo-based MP3 player that integrates with the desktop. For example, he's importing the iTunes Music Library from his Mac and using that as a data source for Ascension. He hasn't showed it yet but the coolest thing with Apollo is how easy it is to make cross-platform applications. For example, using Flex Builder, it is as simple as choosing your platforms and compiling. That's it. There is no platform-specific code whatsoever (those of you who have used Zinc, for example, will understand how much easier this will make their lives.)

Ascension also displays HTML pages to show the lyrics for songs. Apollo can do this. In fact, you can create Apollo applications using HTML as a top-level element. Basically, as has been mentioned to death elsewhere, Apollo allows you to use HTML, Flash and PDF in a transparently cross-platform development workflow. Flash and include HTML and Flash, HTML can include Flash and PDF. In short, it's mucho cool!

Now he's showing Flex Builder 2.0.1 on the Mac. The version he's showing has built-in support for Apollo which is not available in the released version. A version with Apollo support will apparently be released in a couple of months.

He shows how easy it is to compile a Flex application into an Apollo application. His sample application has an HTML control that is fully interactive and yet you can apply any Flash-based transformation, effects, etc. to the HTML control.

Now he is showing a mapping application called Maptacular that uses Google Maps, built by Christian Cantrell. It has an HTML control that loads in google maps. He overlays Flex on top the HTML control -- a tree control that is populated by the VCards on his system. He then drags a VCard to the map and it displays its location. Apollo is going to make a whole new type of mashup possible. A dashup, if you will, that combines data from your desktop with web services and the sorts of rich interfaces and interactions made possible with Flash.

Finally, he is showing a tool that is being built by eBay that makes it very easy to create eBay listings. For example, it uses your webcam to create images for your listing, etc.

You can find more information about Apollo at www.adobe.com/go/apollo.

Adobe plans to have a public beta available on Labs in a couple of months so it's getting close. They plan to have a 1.0 release mid to second-half of this year.

Flash CS3 Sneak Peek

Mike Downey is back on stage. OH NO IT'S THE UGLY NEW ICON! (His slide has the new icon for the next release of Flash.)

New UI

He is showing the new UI for Flash CS3. It's beautiful (apart from the icon and the splash screen.) And consistent. The toolbar icons match Photoshop and Illustrator, for example. He relates how they went out to talk to Adobe customers about how to integrate Flash with the existing Adobe tools. One thing many people have not liked about Flash was the Pen Tool. "Drawing with Flash's pen tool is like drawing with your feet" -- a customer quote! So they changed it. Flash CS3 has the same Pen Tool as Illustrator.

Now he is talking about the unique way that Flash treats shapes. This hasn't changed (since it's actually great for animators.) However, they have introduced primitive support to Flash CS3. There are now new tools such as the Rectangle and Oval primitives. (So you can, for example, add rounded corners to a rectangle very easily.)

About the workspace: They've focussed on making the content be the focus of the UI. For example, it's very easy to collapse the timeline and the PI. The toolbar is now a single column (and that saves some screen real-estate itself). You can expand and collapse the Palettes (when collapsed, it comes a single column toolbar where clicking on the buttons displays the Palette for that panel.)

There is also a new workspace drop-down that gives you quick access to your various panel layouts.

Automatic animation to code conversion

Now he is showing the new automatic animation to code feature developed by Robert Penner. Basically, this feature allows you to create a timeline-based animation (with guide layers, etc.), right-click the timline and select Copy Motion as ActionScript 3 and have Flash convert it to time-based ActionScript code that plays back exactly the same way as your timeline animation. The actual animation is written out as XML (using the native E4X support in Flash Player 9). So you can easily modify the settings of an animation without touching the animation engine itself. The only thing it doesn't work with is shape tweens. If nothing else, this feature alone will make it worth the upgrade.

New Photoshop (and Illustrator) importers

Finally, he is showing the new Photoshop importer (they also have the same feature for Illustrator). The new importer tool gives you access to all of the layers in the Photoshop document, including layer folders and layer comps. It recognizes layers with blend modes, text layers, etc. and allows you do to different things depending on the type of the layer. You also have options to Convert layers to Flash Layers, you can selectively choose which layers (or folders) you want to import and you can choose what type of content you want to convert a layer into.

For example, with a Bitmap layer in Photoshop, you can either import it as a flattened bitmap or as a bitmap image with editable layer styles. You can give it an instance name and set its registration point and set compression settings. You can also choose to set the stage size in Flash to match the canvas size in Photoshop and have the importer place the imported layers at their original coordinates.

The compression engine in Flash is now the same quality as the one in Photoshop.

Grant Skinner on the new V3 components in Flash CS3

He mentions that Flash finally understands how to maximize itself correctly.

V3 Components are built for Flash. They are 25%-40% smaller. 10kb smaller base than the Version 2 components (~15kb). Performance: Lower CPU, higher capacity. Customizability: Skinning (visual and programmatic) is made easier, extending the components is much simpler.

He is now doing a simple performance demo with a List component on stage. He is populating it with a million records. He just selected 200,000 records without delay and is scrolling through without any lag. They've also solved the problem that the earlier components had where external content (eg. images) would flicker when scrolled. Now they don't.

Now he's talking about how it is much easier in the Version 3 components to customize the components using skinning. I'm so happy that we finally have a Flash component set that gets skinning right. To skin a component, you just double click the component and you get a skinning dialog box. Select a skin and you can edit it on stage. The skins use Scale-9 so that corners are maintained and skins scale intelligently.

The style manager now also has massively improved performance and you can do runtime style changes on any number of components without lag. You can also use instances in styles so you can use external media, for example, as icons, etc.

He is now showing how they used skinning to create the color sliders in Kuler.

You also get the performance improvements in ActionScript 3. AS3 gives you development productivity using E4X, RegEx, display list, event model, debugging. He is showing a demonstration of E4X with an example of the Yahoo Maps code where a method with over 20 lines of code in ActionScript 2 is reduced to one line of code with E4X. Performance in AS3 is 10x-100x faster. As a demonstration of the performance, Grant is showing a demo by John Grden, with AS2 and AS3 versions. In AS2, it lags with a single model of a ship. In AS3, there are 10 ships flying by. Finally, there are API additions in AS3 such as BinarySocket, ByteArray, computeSpectrum, etc. He is now showing a computeSpectrum demo with some music and a flaming Blaze demo.

Lynda is now taking the stage again and ending off the keynote.

The understated genius of Mario!

Mario has solved the Wiimote problem on the Flash Player in an ingenious way. He sets the scale of one SWF to the keycode captured in JavaScript and uses the resize event of the Stage to capture this value and pass it to the actual movie using LocalConnection. Rock on, as John would say! :)

Read Mario's post on the subject.

Note: Some of the issues that I mentioned earlier are still present so the ideal solution, of course, would be for Nintendo to implement these key events natively in the Flash Player.

Using the Wiimote buttons in Flash

WiiNintendo.net has posted a list of key codes that the various buttons on the Wiimote generate, stating that they work in Flash and JavaScript. Well, that's half accurate: They do work in JavaScript but not in Flash. Adding a Key listener in Flash doesn't register anything when the buttons on the Wiimote are pressed.

My first thought was to use the Flash/JavaScript Integration Kit (since the player in the Wii is version 7, we can't use ExternalInterface) to relay the key events that the buttons generate from JavaScript to Flash. Easier said than done.

After some fiddling, I got the key codes to transfer to Flash but there are three show stoppers with this method:

First and foremost, it doesn't work when the Flash movie has focus. I tried every method I know of capturing events in JavaScript and none of them results in the JavaScript event handler being called when the Flash movie has focus and a key is pressed.)

Secondly, you cannot have a full screen Flash movie and use this method due to the way Flashjs works (it creates embeds a new SWF every time you call a method in Flash and passes the uid, method to call and its arguments as FlashVars to it. This SWF then uses the uid and LocalConnection to talk to your actual SWF.) So if your actual SWF takes up the whole screen, this additional SWF will result in a vertical scroll arrow displaying on the Wii.

Finally, even if the first two show stoppers could somehow be resolved, when the Flash/JS communication does work (i.e., when the page has focus), there is lag that would probably be unacceptable for games and even for interface items.

Also, the list of key codes given in the WiiNintendo.net article has two typos. The A button has a key code of 13, not 170 and the 2 button has a key code of 173, not 17. So the actual list of key codes for the Wiimote is:

↑ 175
↓ 176
→ 177
← 178
A 13
B 171
- 170
+ 174
1 172
2 173

The next thing I'm going to try is plain old SetVariable. But first a bout of tennis on the Wii with Dave! :) If anyone has other ideas, I'm all ears. Please leave a note in the comments.

Update: So the tennis game can wait: SetVariable doesn't work on the Wii. Damn.

OK, so maybe I can use FSCommand to poll the JavaScript instead... *Doh!* Of course, I can't because functions called from FSCommand can't return values.

OK, so that's it from me. Ideas?

How about: Nintendo, please implement Key events for the Wiimote controller buttons like there are in JavaScript. Pretty please?