Archive for the 'Open Source Flash' Category

The GAE SWF Project

The GAE SWF Project: Knowledge and tools to help you build Flash and Flex apps on Google App Engine

Today I'm releasing The GAE SWF Project, a resource of Flash and Flex-related knowledge specifically aimed at getting you up and running quickly with Google App Engine. If you want to skip all the details and start playing with it, skip to the Getting Started section.

Everyone else, read on!

When Google announced Google App Engine last week, I couldn't believe what I was hearing. It was as if someone had said, "Hey, Aral, tell us what your perfect development environment is and we'll build it for you."

In recent weeks, I had started playing with Python and Django and experimenting to see whether I could use it to build the web application for the Singularity web conference that I'm organizing at the end of October. Turns out that I could not have picked a better time to invest in learning Django and brushing up my Python as Google App Engine is heavily influenced by (and supports) Django and is written in Python.

A framework for the Singularity Conference

Singularity is shaping up to be a really great conference. I'm honored to have a constantly-expanding stellar line-up of speakers and yet the sessions are just one very important aspect of the conference. I find that you get as much out of your social interactions with speakers and other attendees at conferences as you do from the sessions. And Singularity is no exception.

The Singularity conference application is not something you will login to on October 24th and never visit again beyond October 26th. On the contrary, I plan to launching the application as early as possible and add features as we go so that we can start building the community around the conference. This is essential for the organization of the local conference hubs, for building friendships months in advance of the conference, and so that you can influence what the conference ultimately becomes (you do not have to attend the conference to join the online community.)

When I initially announced the Singularity conference two months ago, I stated in the About page that Singularity would have a "focus on open source, the community, and on giving back."

Today, I'm taking the first step towards delivering on that promise by releasing the initial underpinnings of a framework that will eventually power the Singularity conference web application. I present to you The GAE SWF Project.

The GAE SWF Project

The GAE SWF Project (hey, Google chose the name, I only provide the juvenile attempts at humor) is a resource of Flash and Flex-related knowledge specifically aimed at getting you up and running quickly with Google App Engine. The initial release contains a proof-of-concept Flash 9 client showcasing a pre-alpha version of The GAE SWF Framework. The framework is a very light-weight combination of Python and ActionScript 3 that uses some of the best open source components available today on the Flash Platform and Python ecosystem. It is inspired at its core by best practices and a pragmatic approach to application development.

The proof of concept (and, indeed, the whole project) specifically targets Google App Engine. This is by design. The framework is not a generic one (although, by all means, feel free to get inspired and port it if you wish). The dedicated focus is part of the appeal. It means that we can make things simpler.

There will be no abstraction for the sake of abstraction and no premature abstraction; the framework will evolve by encountering real-world problems and solving them.

Finally, keep in mind that you are viewing the fruits of three days of work at the moment (this, in itself, should be testament enough to how easy -- and fun -- Google App Engine makes development). It is early days but I feel that we've made a good start. I hope to hear your thoughts and feedback in the comments.

The Proof of Concept

The proof of concept is built on Google App Engine using Google's webapp framework.

It showcases several fundamental architectural considerations, the most important of which I've outlined for you below.

HTML and Flash in a tree...

You use handlers in app.yaml to host a mix of Flash and HTML content, including the Flash Remoting gateway, in a single Google App Engine app.

Embed Flash content using SWFObject

SWFObject is the way to embed Flash and Flex applications in your HTML. Use it. 'Nuff said.

Deep links

You implement deep linking using a combination of server-side Python and SWFAddress so that both SWFAddress-style and regular URLs are supported. Regular URLs are translated to SWFAddress-style hash/anchor URLs on the server.

Thus, both of the following URLs are valid ways to reach your profile page on the proof of concept Flash 9 client:

Regular URL:

http://gaeswf.appspot.com/examples/initial/profile

SWFAddress-style URL:

http://gaeswf.appspot.com/examples/initial/#/profile

Flash content that obeys browser text-size changes

Users with poor eyesight or in environments with reduced-visibility (such as bright sunshine outdoors) may want to increase the size of the text displayed in the browser. By default, Flash and Flex content does not react to these text-size changes. However, it is possible to make Flash content obey browser text-size changes and the proof of concept implements one such method that does not involve any alterations to the Flash app.

(You can read more about similar issues -- and see some juicy Flash myths debunked -- in my review of the talk I gave at Highland Fling this month titled Bare-naked Flash: Dispelling myths and building bridges.)

PyAMF

PyAMF is a Flash Remoting implementation for Python. It has a dedicated and responsive group of passionate developers working on it, led by Thijs Triemstra, Nick Joyce, and Arnar Birgisson. On Tuesday, the team released PyAMF 0.3 with support for Google App Engine.

The GAE SWF Framework uses PyAMF as a core component to communicate with the server and the various Google App Engine APIs. It is currently running PyAMF 0.3.

The PyAMF gateway is setup as a regular mapping, and mapped to /gateway in app.yaml.

Users API

You use the Google App Engine Users API to login and out of the Flash application. The current Flash 9 proof of concept implements one of three possible ways of handling logins (see the note in my earlier blog post about the other two ways.)

Intelligent forwarding after login

When you hit a deep link in the application without logging in, you are automatically forwarded to the link after you login. This is a behavior that you are accustomed to seeing (and expect) in HTML-based applications but I have rarely seen it implemented in Flash and Flex applications.

DataStore API

The Google App Engine DataStore is a massively scalable database based on Google's Bigtable (the same distributed database that powers their search and services like Google Earth).

The proof of concept has a profile section where you can fill in your name and a URL (the Users API currently does not provide your GAE app with the user's name, just their email address). This data is saved via PyAMF and the DataStore API.

(All server-side services are in the /services package.)

Client-side and server-side validation

The Profile Screen shows you how to implement two different types of validation: simple client-side validation and server-side validation.

The Name field performs simple client-side validation that stops the user from submitting the form without entering a name.

The URL field, on the other hand, actually hits the server and asks the DataStore to verify that the URL is valid. When you think about it, it makes sense to use server-side validation code to validate more complex data types using the exact same code that the DataStore API uses.

The user experience is managed via visual cues that are carefully scripted using the excellent KitchenSync AS3 sequencing library by Mims Wright. (Mims just added me as a project member so I can contribute a small update I blogged about earlier.)

(I'm still working on tweaking the timing of the type wait duration for firing the server-side validation code to make it as seamless as possible.)

As the framework develops, I know that the KitchenSync library is going to be an essential, core element, and I look forward to contributing back as much as I can to the project.

Mail API

The proof of concept also makes use of the Google App Engine Mail API to send email confirmations to your Google Accounts email address after you update your profile.

When initially working with this, I was searching for a simple way to monitor the mail that was being sent from the app. Although the Development Web Server allows you to specify an SMTP server when you start it, I couldn't get it to work with either GMail or my web host's mail server. And setting up sendmail or postfix was a pile of worms I didn't want to sample.

Instead, I found a simple, open source SMTP server written in Python that's perfect when developing locally with the Development Web Server. It's in The GAE SWF Project app that you can download. To start it, simply change to your The GAE SWF Project folder and type:

./monitor_mail

You will see all email sent from your application in the Terminal window. (Note: I run on a Mac and all the commands in this article are meant to be run in Terminal on OS X. You may need to tweak them slightly for your operating system of choice.)

CSS, etc.

I may introduce myself as a Flash Developer but that doesn't mean that I don't care about the rest of the web. With good friends like Andy Budd, Richard Rutter, Paul Annette, and Jeremy Keith living almost a baseball-bat-wave away from me, I'd be scared silly implementing a new site with anything less than pristine markup. So that's what I've strived for here and I hope I've at least come close. (I did use one <br/> tag, for which I feel very dirty indeed!)

Nearly all of the credit for the CSS goes to the excellent YUI Grids CSS library that Rob Knight clued me into via Twitter last week when I was battling with altering the K2 theme on Singularity to make it into a cross-browser three-column fluid layout.

(The scale9-esque fluid download cell is courtesy of the even more rounded corners with CSS technique.)

The HTML content is structured using several Django templates, which are supported by Google's webapp framework.

Finally, the Flash client uses the TabBar component from the open source Yahoo Astra Flash components and Uza's AS3 Global Object to implement several global convenience properties (like the current SWF's URL).

Getting Started

Getting started with The GAE SWF Project couldn't be easier.

1. Download and unzip

First off, download the Google App Engine SDK (includes the local Development Web Server and webapp framework.)

Next, download the latest release of the The GAE SWF Project and unzip it.

(Or, you can check out the unstable, bleeding-edge version from The GAE SWF Project Subversion repository's trunk on OSFlash.)

2. Start the server

Open up Terminal and navigate to the folder you unzipped The GAE SWF Project to. To start the Development Web Server type:

./start

This is a convenience script that I made that starts the Development Web Server and sets the mail server as localhost:5000. You can change these in the script of just use dev_appserver.py . to start it up without mail support.

If you want to monitor the email that gets sent, open up a separate Terminal window and, in The GAE SWF Project folder, type:

./monitor_mail

3. View the app and start hacking!

Now that the app is running, view it in the browser by hitting http://localhost:8080.

You can now open up the source folder and start exploring!

Trace you, trace me, trace it for always...

Wow, did I just paraphrase Lionel Richie?

Anyway, I find it useful to tail the Flash trace log (especially to see trace results in the browser and online). Here's how you do it:

Before you start, you need to enable logging by creating a file called mm.cfg in /Library/Application Support/Macromedia.

In it, enter:

ErrorReportingEnable=1
TraceOutputFileEnable=1

You only need to do this once. After that, whenever you want to tail the log, open up a new Terminal window and type the following, replacing USER with your home folder:

tail -f /Users/USER/Library/Preferences/Macromedia/Flash\ Player/Logs/flashlog.txt

Play, enjoy, share, have fun!

As I state on The GAE SWF Project site, I hope that this open source effort will help you to get started quickly with building Flash and Flex application on Google App Engine. In the past few days, I have had more fun developing this than I can remember in a long while. I love Python, I love Django, I love Google App Engine, and I love Flash and Flex. To have them all together... well, that's a dream toolset, right there!

And, there's something to be said about writing your app and then letting Google handle the rest. Personally, I can live with that.

(Oh yes, and I do desperately need to talk to someone at Google about hosting the Singularity conference web application on Google App Engine with regards to the quotas -- if you know whom I should contact, please either let me know directly at aral {at} aralbalkan(.)com or leave a comment below -- thanks!)

The GAE SWF Project is currently a proof-of-concept; it's a three-day old baby that I hope will blossom into a useful resource.

I hope you you enjoy it and I hope that it makes your life a little easier or at least gives you food for thought.

Play with it and let me know what you think in the comments.

Yahoo! Blocks! OSFlash!

If you have a Yahoo Mail email address, chances are you are being kicked out of OSFlash mailing lists as we speak by the Mailman mailing list software that we use. If your favorite list or lists have gone silent suddenly, this is the reason. Until Yahoo! fixes this or tells me what I need to do to fix it, I would suggest that you use a non-Yahoo email address to subscribe to OSFlash mailing lists.
Continue reading 'Yahoo! Blocks! OSFlash!'

2nd OSFlash conference recordings

The 2nd online OSFlash conference is still going on (John Grden's giving his Red5 talk at I write this) and Firdosh has already made the recordings of the day's earlier sessions available.

Here are those links:

Aral Balkan Keynote
Ralph Hauwert Papervision 3D
Aral Balkan SWX
Nicolas Cannasse Haxe Programming Language
BREAK
Firdosh Tangri ASWing Component Framework
Igor Costa Flex Applications using Flex 2 SDK and Granite Data Services
John Grden The Red5 Project

I'll update this post with the rest of the links when they're available.

2nd Open Source Flash Conference this Friday

2nd Open Source Flash Conference on June 15, 2007. Starts 3pm.

The second OSFlash conference will be taking place online, this Friday at 15:00 GMT/UTC (11:00 EST).

Continue reading '2nd Open Source Flash Conference this Friday'

AsProject: rails-like toolset for ActionScript

AsProject Video Demo Screenshot

Luke Bayes and Ali Mills of asunit fame just released AsProject, an open source ActionScript development toolset that streamlines the open source development process by giving you a rails-like experience.

Check out the AsProject demo video.

This is very cool. I must set aside time to see how Arp can be integrated into this.

OSFlash: swfresize

James Everhardt has just released swfresize on OSFlash.

According to the swfresize page on OSFlash, swfresize is "a small bit of JavaScript that helps a 'full-screen' Flash application be as large as possible and still maintain it’s aspect ratio, and keep everything within the viewable area of the browser."

Swfresize works with SWFObject and takes just two lines of code to implement. It keeps the aspect ratio of your SWF file and stops off-stage assets from appearing.

Basically, it sounds like a better alternative to setting your movie to have 100% width and height.

Although the link to the swfresize page on James's blog doesn't seem to be working at the moment, the download link for the swfresize.zip file does work.

See swfresize on OSFlash.

AsUnit-X gets an icon!

AsUnit-X updated with new icon I received an unexpected email from Jason Bednarik today with a lovely new icon for AsUnit-X attached to it. Jason apparently created his own application bundle for asunit previously and had an icon he made for it which he has generously let me use for AsUnit-X.

Thanks, Jason!

Download the updated AsUnit-X with new icon
(DMG file, OS X; 11MB).

AsUnit-X: AsUnit XUL UI for OS X

AsUnit-X: AsUnit XUL UI for OS X

The XUL UI for the excellent AsUnit by Luke Bayes and Ali Mills has been missing an installer/application bundle for OS X for a while now so, this morning, I decided to create one. After all, now that I have a Mac, how could I pass up the chance to contribute both to the Mac community and to one of my favorite open source Flash projects at the same time?

If you're in a hurry, here's the download link:

Download AsUnit-X (10.9MB), the AsUnit XUL UI for OS X (see what I did there with the name? Clever, I am, I tell you!) :P

It's a standard Mac application bundle. To install it, just mount the DMG and drag the application icon to the Applications folder icon. In other words, just install it like any other Mac app.

Here are a quick series of steps for setting up a new project using AsUnit-X:

  1. Launch AsUnit-X
  2. Click the + icon next to Projects to create a new project using the Wizard
  3. Enter a name for the project. It doesn't matter what you enter here, it's a description solely for your benefit.
  4. Under templates, choose the version of ActionScript that you want. For ActionScript 2, there are two options. I selected the one for Flash 8, which uses the AsUnit 2.5 framework. Based on which version you select, make sure you include the correct framework in the classpath of your Flash movie later on.
  5. Select the source folder where you want AsUnit-X to create your class files.
  6. Select the folder that you want AsUnit-X to use to create your test cases. For simplicity, you can choose the same folder.
  7. Next, you need to tell AsUnit-X where the default Flash classes reside. Click the Add button to add the class path (don't be confused by the text at the top of the screen. I spent a few moments trying to paste the class path in there by mistake.) For a default Mac installation, the default Flash framework classes are found in Users/{your user name}/Library/Application Support/Macromedia/Flash 8/en/Configuration/Classes
  8. Congratulations, you've completed the wizard and set up your project! (You don't have to use the wizard to enter this information, you can use the main UI. You can also alter this information at any time from the main UI.)

And some more steps for creating a class file and unit tests for it:

  1. Enter the name of a class in the Class Name text box (you can enter a fully-qualified class name that contains package information and AsUnit-X will create the package structure for you).
  2. Select the access modifier for the class constructor (or make it a Singleton) using the Constructor radio buttons.
  3. (Optional) Select a superclass at this point by either typing in the name of a class or select a class from the classpath by clicking the Choose button.
  4. (Optional) Add any interfaces that you want your class to implement by adding them to the Interfaces list box by using the Add button.
  5. If you want AsUnit-X to automatically create a test case for your class, check the Create Test Case checkbox. You can choose to make the test case a standard one (synchronous), a Mock Object or an asynchronous test (e.g., for testing classes that rely on externally loaded data).
  6. If you want AsUnit-X to automatically create test suites for your class, check the Generate Test Suites checkbox.
  7. Finally, click the Create button to create your class and your test case. Click the Run Now link next to Generate Test Suites to generate your test suite.

And, finally, some steps for actually running the tests. To run the tests, you will need to create an FLA that is known as the Test Runner. To do this:

  1. Open up Flash and create a new FLA. Call it MyTestRunner or something equally exciting.
  2. On Frame 1 of the FLA, add the following code: MyTestRunner.main();
  3. Before you do anything else, add the AsUnit framework to your classpath. To do this, open up Flash's preferences (Flash Professional → Preferences...), select ActionScript from the Category list box and click the ActionScript 2.0 Settings button in the Language field. Use the + button to add a path to your classpath. The AsUnit framework is included in the AsUnit-X application bundle so you can point to it from there. For a default installation, the path should be: {Your Computer's Name}:Applications:AsUnit-X.app:Contents:Frameworks:asunit:as25. Change the last folder to the version of the framework you want (or, even better, add all three -- you'll only need to do this once and the settings will work with all of your projects.)
  4. Next, actually create the MyTestRunner class. Here's how a simple one looks:
    [as]import asunit.textui.TestRunner;

    class MyTestRunner extends TestRunner
    {
    public function MyTestRunner()
    {
    start(AllTests);
    }

    public static function main():Void
    {
    var runner:MyTestRunner = new MyTestRunner();
    }
    }[/as]
    I'm not a big fan of using a static main() method in Flash but, in this case, it makes sense so that your test suites can be run by both the Flash IDE (Macromedia compiler) and MTASC.

  5. Test your MyTestRunner FLA and you should see the default AsUnit interface appear with the familiar red bar that tells you that your test case (with an automatically generated failing test) was added to your test suite correctly.

I realize that these are quick notes but I thought I'd jot them down here as I had a lot of difficulty trying to find documentation or tutorials for AsUnit, especially the 2.5 branch. I will try and create a more illustrated tutorial if I get time, with screenshots and whatnot.

If you're interested, here are the steps I followed to create the bundle:

  1. Install the Mac version of the XULRunner framework.
  2. Downloaded the OS X build of the AsUnit XUL UI from asunit.org.
  3. Create an application bundle (a folder called AsUnit-X.app) in Finder and populate it according to the excellent instructions on the Deploying XULRunner 1.8 page at Mozilla and Ricardo Pacheco's XULRunner on OS X blog post. The exact rsync command to run is rsync -rl /Library/Frameworks/XUL.framework/ /path/to/your/bundle/AsUnit-X.app/Contents/Frameworks/XUL.framework/ (the Mozilla docs are a bit confusing on which folder you need to copy.) Make sure you create the Info.plist file based on the one in Ricardo's blog post. If all goes well, you should a running Mac app at this point.
  4. Add the framework. I added this into a folder called asunit in the Frameworks folder in the bundle.
  5. Finally, package it into a DMG. I found these instructions for creating a DMG by Remko Tronçon to be very useful and owe a debt of gratitude to Adium, from which I ripped the background graphic and symlink for the Applications folder. AsUnit-X doesn't have its own icon yet but that may change in the near future (OS X-style icon donations are welcome!)

    While creating the DMG, I came across an issue that caused me some delay (which was completely unnecessary!) After converting the disk image to a compressed image using the Disk Utility, Finder would no longer open the mounted image in icon view (on my system, it defaulted to column view). I saw that others were having this problem also and initially attempted to address it by using the pkg-dmg perl script from Mozilla. Unfortunately, that didn't like the symlink to Applications and tried to copy the actual Applications folder over and failed. So, I decided to follow the instructions on this thread but that didn't work either (although I am digging the power of the hdiutil command.) Finally, I decided to see if throwing money at the problem would work and tried out Drop DMG and FireStorm, neither of which worked. It was only at this point that I realized that there wasn't anything wrong with the image files I was creating but that I had had "Open new windows in column view" checked in my Finder preferences. Doh! Unchecking this showed that the image files were displaying correctly after all!

I hope this makes AsUnit easier to access for developers on the Mac platform and that you enjoy using AsUnit-X.

Download AsUnit-X (10.9MB)

The Web Standards Project is wrong on SWFObject

The web standards project has a terribly elitist post by Ben Henick that is an unfair and uninformed dismissal of SWFObject. In the post Ben states:

As for SWFObject, it serves a purpose that I might have someday in the face of a tight deadline, relaxed project requirements, or a requirement for the most recent version of Flash. However, I’ve been through every line of SWFObject’s code and can state with confidence that while it obeys the letter of the W3C Recommendations, it totally disregards their spirit.

I must always be faced with tight deadlines and relaxed project requirements because I use SWFObject quite often.

So if we shouldn't use SWFObject, what is Ben's recommendation? Apparently, according to The Web Standards Project, we are supposed to use methods that embed SWF files using only the Object tag. If you feel that there's a distinct disconnect between this recommendation and your own experience of reality as a Flash developer, join the club! I'm not going to go into detail about why this is such a bad idea here as Geoff Stearns has already done a great job of responding on his blog post. I believe that the following quote from his post summarizes it best:

Using only the object tag to embed your plugin content (especially Flash content) is fucking stupid.

I highly recommend that you read Geoff's post and I have to say that I agree wholeheartedly with it both in letter and in spirit.

OSFlash Zeroi project makes logging in ActionScript more flexible

Ralf Bokelberg and Sönke Rohde have released Zeroi on OSFlash.

Zeroi is a logging abstraction layer that lets you use any logging system (SOS, admin tool, luminic box, ...) in your MTASC projects, without code changes in your application. Here's how it works, according to Ralf's email to the OSFlash mailing list:

Inside your app you only use trace statements. The traces are forwarded to the logging system of your choice. That's what the name Zeroi stands for: Zero Impact.

Sönke Rohde added the possibility to configure your logging system by using XML. You can filter logs on a class or package basis, e.g. suppress every log from class XY with a loglevel <= WARN

Find out more about Zeroi on OSFlash.






Bad Behavior has blocked 0 access attempts in the last 7 days.