Google+ API Available

Google has just announced that the Google+ API is now available to the public:

http://googleplusplatform.blogspot.com/2011/09/getting-started-on-google-api.html

This is the first release of the API, and it only allows you to get read-only access to “public” information. I’m still a little unclear on what “public information” means (I mean, you DID type it into a social network…), but it looks like this API enables you to get the typical profile information as well as a list of that person’s “activities,” which are posts, check-ins, and shares. This release does NOT enable viral channels like requests, which are crucial to application/game discovery.

Here is the technical reference for the real meat of the story:

http://developers.google.com/+/api/

Adobe Edge Public Preview Available

The first public preview of Adobe Edge, Adobe’s IDE for building HTML5 applications (think: Flash for HTML5), was released on Adobe Labs today:

http://labs.adobe.com/technologies/edge/

This is JUST a preview, so it’s a pretty rudimentary version of the final product. So far it includes:

  • Create new “compositions” or edit existing HTML applications
  • Place and Animate PNG/SVG/JPG/GIF images
  • Place and animate HTML text

Some major features NOT included:

  • Interactivity
  • Code Support

So basically you can create animated banner ads, but you can’t click them. That’s not terribly impressive by itself, but it is a major milestone, hence the preview. Edge is scheduled for final release in 2012.

If anyone can create an IDE for building HTML5 applications, it’s definitely Adobe. In fact, I’m not aware of anyone else who is even trying. I still think Edge is going to be limited to building simple applications, prototypes, motion tests, etc., and large applications will be done the old fashioned way by hand, but if you want to build a relatively simple app, and you want to do it, really, really fast, Edge looks like a great choice.

Unity vs Flash for Cross Platform Development

For the past month or so, I’ve been working with Unity 3D, a 3D engine and IDE built by Unity Technologies. Prior to this experience I had only heard vague references to Unity, but it hadn’t really been on my radar until now. However, now that I’ve had a chance to dip my toes into it, I’m quickly becoming a fan. To sum up my experience:

Unity has done for 3D gaming what Flash did for 2D animation.

We’ve been looking at Unity as a potential solution to the great “cross platform” problem: How do we build one code base and deploy it to mobile devices and the web?

On the web, Unity has approached this in a similar way to Flash, where the end user must install a browser plug-in to see the content. However Unity’s content has much greater access to the system’s resources, in particular the 3D rendering pipelines, which Flash is just starting to add with the Molehill APIs. Result? Edge to Unity.

On mobile devices, both cross compile to native apps that run as native code on the phone. Result? Call it a draw.

When you look at building for both platforms using the same code base, the problem gets a lot more complex, and neither has really “solved” the technical challenges you’ll face. The first is handling different input methods. A lot of web interaction relies on rollover transitions for user feedback, however that interaction doesn’t exist on mobile devices which are primarily touch-based these days. Solving for both input methods can be partially accomplished through good user experience design, however it’s nearly impossible to avoid writing custom code for each target platform.

The second problem that neither Flash nor Unity can solve is asset loading on different platforms. On mobile, you have to respect the user’s bandwidth, or be prepared for the network to be unavailable, so you package all of your assets in the initial download and load very little at runtime. On the web, you can basically assume broadband these days, so you make your initial download as lightweight as possible, preload the bulk of your app, and lazy load the rest of the assets you need.

There’s no way for either Flash or Unity to solve these problems, so expect around 25% of your code base to be affected and change drastically when developing for a new platform.

With that said however, Unity is still a very impressive tool for building 3D games and simulations. It was built from the ground up with multi-platform development in mind though, so it has some nice features, in particular its well defined asset pipeline, and it can certainly push the barriers of production value beyond Flash, which mobile gamers expect, and web gamers appear to be trending towards.

Here’s a few more quick points of how Unity compares to Flash, in the context of building for web and mobile:

Pros

  • Much better graphics capability and overall performance for what you get
  • Potential for more advanced game play (particularly physics-based)
  • The Asset Pipeline (getting art, sounds, and animations into the game) was well thought out from the beginning, so there’s basically one way to do it, and it’s easy.
  • You can write your client and your server in the same language (C# is the default), which allows you to do logic on either side to improve performance, security, possibly maintainability.

Cons

  • The plug-in barrier. Can you convince your users to install a new plug-in and restart their browser to view your content?
  • The production values expected from a 3D application are going to be higher than the typical 2D experience. If you can’t meet the user’s expectations in that realm, you may have done yourself a disservice.

In the end, I really think it comes down to your creative vision. Choosing a technology is about making trade-offs, so when you ask “What do we want to build?”, you have to weigh what Flash does well, 2D animation and vector graphics, versus what Unity does well, physics and 3D.

Tweenlite ThrowProps Plugin

Want to add flicking and tossing behavior to your UI like iOS and Google Map? Tweenlite has just added support for those types of tweens.

Usually when you’re creating tweens, you have to know a lot of information up front. You have to supply parameters to the tween such as where it starts, where it ends, and how long it should take. Those are the kinds of parameters that you don’t know ahead of time when it’s dependent on how and when a user drops a scrolling list.

Although it’s not impossible, or even overly difficult to figure out those values when it’s time to create the tween, the real power of TweenLite is that it simplifies the process for you in an excellent API that’s easy to understand and super quick to leverage.

The plugin is available now to paying Club Greensock members.

http://www.greensock.com/throwprops/

Code Smells

One of the hardest parts of building large applications when there’s more than a single developer involved is talking about the code that the team already has and is in the process of producing. Code is inherently abstract and difficult to describe, which makes the quality of the code even more abstract. Code quality is often times subjective as well, as people can have different points of view on the trade-offs that are made in a particular solution to a problem. Code quality can even be a very sensitive and personal issue to the people involved in writing the code as everyone sees it as a direct evaluation of their performance and skill.

It’s important when you’re having these types of conversations that you avoid miscommunication and understand each other clearly. Code “smells” help establish a vocabulary that can turn the abstract concepts expressed in code into something more concrete that is easier to point out, talk about, and generate alternatives to.

The Wikipedia article on Code Smells is as good a resource as I’ve ever found on them, and if you love reading about programming as much as I do, it’s incredibly interesting stuff.

The referenced pages are also great, particularly the one on Anti-Patterns, which describes practices and characteristics to avoid at all levels of an organization, all the way down to the code. If you can relate to too many of these anti-patterns, you may need to start thinking about why and how you can fix them!

Adobe Previews “EDGE” HTML5 Authoring Tool

We all knew Adobe had to respond to the recent HTML5 swell, so I think that the arrival of an HTML5 authoring tool, named “Edge,” is a pretty predictable response from Adobe.
Adobe Edge
In this video, Mark Anders demos a very early prototype of Edge which has a very familiar, Flash IDE-ish interface.
The famous Flash timeline is back, as well as the concept of “symbols” applied to the HTML context.  Most interesting to me is that Webkit is at the heart of the tool, rendering engine driving the live preview of the content.
In the video you also catch a couple glimpses of the source code that’s being generated, which at this point actually looks relatively maintainable and logical to the human programmer.  Granted, this is a pretty constrained scenario for the tool.  I predict that Edge will fill a role similar to Dreamweaver where it’s useful for less technically able people to build prototypes and relatively simple applications, and medium to large applications will still be created the old fashioned way, one line at a time by hand.

Introduction to MXML

If you’re here because you’ve just heard about MXML for the first time and have NO clue what it is, you should start by reading Wikipedia’s MXML article.

Some Background
MXML is an XML-based language that is functionally equivalent to ActionScript. When MXMLC compiles MXML, first it translates it to ActionScript, then compiles that ActionScript into bytecode. In fact, if you pass the -compiler.keep-generated-actionscript argument to MXMLC, you can actually see the ActionScript that is generated from your MXML class. There’s a common misconception that using MXML requires using the Flex Framework, or that Flex is MXML and vice versa. Those are not true. MXML is a declarative language, like HTML. Flex is Adobe’s UI component framework. The two are not dependent on each other, which the South Park project demonstrates.
MXML in a Nutshell

Here’s an example of a default MXML file, which we’ll examine below:

<?xml version=”1.0″ encoding=”utf-8″?>

<s:Application

xmlns:fx=”http://ns.adobe.com/mxml/2009 xmlns:s=”library://ns.adobe.com/flex/spark

xmlns:mx=”library://ns.adobe.com/flex/mx

minWidth=”955” minHeight=”600>

<fx:Declarations>

<!– Place non-visual elements (e.g., services, value objects) here –>

</fx:Declarations>

</s:Application>

Doctype Declaration

<?xml version=”1.0″ encoding=”utf-8″?>

The first line is required for all XML documents. It’s not unique to MXML and is essentially telling any parsers that read this file what to expect. You can basically take it for granted and not have to worry about it as long as you’re creating and working with MXML files within Flash Builder. If you’re using another editor, just make sure that you’re saving your files using utf-8 or you’ll run into nasty compilation problems.

Root Node

<s:Application minWidth="955" minHeight="600">

...

</s:Application>

There can only be 1 root node of any MXML document, and all other nodes must be contained by the root node. You can’t have 2 top level nodes in an MXML file, just like you can’t have 2 public classes in a single ActionScript class file. Also, the root node is normally a DisplayObjectContainer so you can place DisplayObjects within it. You could potentially create non-visual classes/components in MXML, but MXML’s strengths are laying out UI elements and rigging up event handling, so you would probably be better off using ActionScript in that case.

Namespace Declarations

xmlns:fx="http://ns.adobe.com/mxml/2009"

xmlns:bd="com.bdement.*"

Namespace declarations are equivalent to import statements in ActionScript, but they are a special attribute that must be present in the root node. The default namespace is http://ns.adobe.com/mxml/2009, which is required to make MXML “work,” regardless of whether you’re using the Flex Framework or not. xmlns:fx means “use a namespace called ‘fx,’” which lets you write tags that begin with <fx: and gives you access to all of the classes within that namespace. You can also import any package as a namespace by specifying it like the 2nd example.

The actual namespace (fx or mtvn, in the above lines) is arbitrary. For example, in the 2nd line I used “bd” as my namespace, but I could name it anything. Namespaces aren’t globally defined, so you can change them from class to class, although as a best practice you should name them consistently throughout your project.

Nodes

Every element within an (M)XML document is known as a node. Nodes are equivalent to declarations in ActionScript. Every time you specify a node like <ns:Object />, the resulting ActionScript will look like “new Object().”
Attributes

MXML gives you access to all of the public attributes exposed by a class. They’re set by declaring a value for them in MXML, like this:

<s:Application width="955" height="600">


This is the functional equivalent to the following ActionScript:
var myApp:Application = new Application();
myApp.width = 955;
myApp.height = 600;

Even in this simple example you can already see how MXML’s declarative structure is well-suited for “declaring” UI layouts.

Dynamic Attributes

Often you’ll want a particular value to change at runtime, and for that change to have some kind of effect on your UI. For example, a label that changes text when you click something.
To specify a dynamic attribute, wrap a reference to it in curly braces, as shown here:
<fx:Declarations> <fx:String id=”labelText>My Label</fx:String>

</fx:Declarations>

<s:Label text=”{labelText}/>

In this example we declared a String called “labelText,” and a Label that uses labelText’s value. The String is wrapped in a “Declarations” tag because it’s a non-visual element. All properties declared like this are given a public scope and are “bindable.” We’ll discuss more about data binding below.
As an alternative, you could also specify properties in script:

<fx:Script>

<![CDATA[

[Bindable(event="labelChanged")]

private var labelText:String = "My Label";

]]>

</fx:Script>

<s:Label text="{labelText}"/>

Here you’ll notice that instead of a Declarations tag, we used a Script tag, which contains a CDATA enclosure. The CDATA enclosure tells the MXML parser that content within the enclosure is “character data,” and will not follow (M)XML syntax.
The [Bindable] metadata tag means that the next property is available for data binding. Data binding is a handy, but often misused feature in MXML. For complete information on data binding, read Adobe’s Bindable Metatag Documentation.
Key Point: The key thing to know about data binding is that when you write a [Bindable] tag, always, 100% of the time, include a unique event name. If you don’t, your performance when using data binding will get really bad, really fast.
The reason is that if you don’t supply an event name, it defaults to “propertyChanged.” Then every time a property changes, Flash has to figure out which property changed, which becomes more expensive as you have more properties that are all dispatching that event. Also, if you view the ActionScript files generated from your MXML classes you can actually see how vastly different the generated code is when you do and don’t supply a property name.

Event Handlers

Event Handlers are specified in MXML very similarly to how attributes are specified, except they refer to a function rather than a property. For example:

<fx:Script>

<![CDATA[

protected function button1_clickHandler(event:MouseEvent):void

{

trace("Clicked!");

}

]]>

</fx:Script>

<s:Button id="button1" click="button1_clickHandler(event)"/>

You can probably see the connection pretty easily here, but notice that there are no curly braces in this case. Also notice that the magic variable “event” is being passed to the handler. “Event” is the naming convention used in MXML for the event that will be passed to your event handling function. You could also write event handlers like this, although I do not advocate it in all but the most trivial programs, I’m only showing this as a reference to show how the magic “event” comes out of nowhere:
<s:Button click="trace(event.type)"/>

Flex 4.5 SDK Build Released

Adobe has just released their next build of the Flex Framework, codenamed “Hero,” on Adobe Open Source.

Some of the mobile and more advanced features aren’t available until they release a new version of the player, but the new components they list are.  What I thought was particularly interesting was a few of the enhancements being made to the Spark Image Component, which is meant to replace the Halo Image component.

The Spark version is enhanced to provide BitmapData sharing across instances, which both reduces memory footprint and perceived loading time when loading the images multiple times.  Adobe took the Flex Framework a big step forward when they went from 3 to 4, which I think is shown in how they’re just now getting around to releasing fundamental components like Image.

It’s fun and efficient to use the Flex Framework for getting UI work done fast, but at the same time it makes me a little nostalgic for the time when I needed to write neat little gadgets like an image cache myself.

FITC San Francisco

FITC held it’s first ever event in San Francisco last week where they brought together some of the most creative and innovative minds from Flash’s design and development communities.  I had heard about previous FITC events and their increasing reputation for great speakers, educational sessions, and never-before-seen demos experiments, so when I heard they were coming to my new home, San Francisco, I have to admit I got a little giddy.
They sent out an early call for volunteers which I jumped on in a heartbeat.  Being a volunteer was a no-brainer for me, it saved a ton of money and for just a little bit of my time I got access to most of the sessions as well as an inside look into how FITC works and what it takes to put it together.  I met several of the FITC staff and chatted with them about their jobs of putting on these events all across the world.  It’s an impressive feat for them to orchestrate so many moving parts remotely, fly to a new city and have them all fall into place, then turn and do it all over again just a couple months later in another new city!  I also thought it was really funny how all these Canadians were caught totally by surprise by San Francisco’s chilly Summer weather, it was warmer in most parts of Canada than it was in SF!
I went to several sessions including the Adobe Keynote with Kevin Lynch, Flex 4 Lifecycle Best Practices with Aaron Pedersen & James Polanco, and High Performance Mobile Content with Flash with Mike Chambers
The Adobe Keynote was great and renewed my confidence that Flash is and will be an integral part of the Internet for a long time to come.  For example, cell handset makers are starting to advertise that their devices support Flash, even putting the Flash Player logo on their packaging.  I also asked Kevin Lynch a question that has been burning in my mind for a while about the capabilities of CS5’s Device Central.  His answer was really, really impressive.  Normally you would expect the first iteration of a major feature like Device Central to be somewhat underwhelming, but not so in this case, just a few of the features are:
  • Simulation of all input types and layouts – In Device Central you can see a little picture of the actual device your testing and play with each and every one of the buttons and input controls it suppors
  • Memory and CPU Simulation – What’s more important on a mobile device than performance?  (See below!)  Device Central actually simulates the capabilities of the device you’re testing to let you know how your content will do.
  • Radio interference – Kevin told a story about how some developers were actually taking test devices into elevators to test how their application performs with degraded reception, so they built this into Device Central!
  • Screen glareWhaaaat? Does your application have enough contrast to be seen when the device is being used outdoors?  Device Central can help you find out.

Device Central is powerful, but no tool can guarantee that your app will work as designed in real world scenarios, so don’t forget to test yourself, on a real device, because as we all know: ain’t nothing like the real thing, baby.

And finally, I attended Mike Chambers’ session on mobile application performance.  I was going in hopes of picking up tips to apply to my day job as a game developer, and I wasn’t disappointed, as most of Mike’s tips could be applied to virtually any application, but is especially important when running in under-powered mobile environments.  Here are my Cliff’s notes:
  • Air 2.5 beta open – Open to anyone who registers.  Repurposes most of the work done for iPhone development and applies it to Android.
  • Bit.ly/as3performance – Grant Skinner’s performance testing framework
  • Github.com/MikeChambers – Mike Chambers’ Simple Game Framework, a set of utility classes to perform various game related functions like a Centralized Game Loop, Object Pooling, Caching, etc.
  • Mobile support coming to next version of Flash Builder (don’t know any details of what this means)
  • ALL vector rendering in AIR 2.5 is done via the GPU, which improves performance on all devices and improves battery life on mobile devices
  • All vectors on stage are rendered, regardless of screen position.  i.e. If you move an object off-screen, it is still iterated over in the rendering phase, wasting resources.  To improve this, set visible = false.
  • A new property called “cacheAsBitmapMatrix” is now available in AIR 2.5, and will be available in the Flash Player in a near release.  Right now when you set cacheAsBitmap=true, and then scale or rotate the bitmap, it has to be redrawn.  By setting the cacheAsBitmapMatrix to a matrix (usually just the identity matrix), you enable bitmap caching and greatly increase the performance of any redraws that occur.
  • Performance tip:  Do anything you can to prevent redraws (check the redraw regions to figure out what’s being redrawn).  Things that force redraws are: Using the drawing API, changing/moving an object or it’s children, removing an object/child, or occluding non-cached objects.
  • Setting Array/vector.length = 0 is faster than setting array/vector = new Array/Vector
  • Object instantiation is very expensive, so instead of disposing objects, you can put them back in the pool and reuse them later.
  • Mouse events are cheaper than touch events on mobile devices, and single finger touch events are automatically translated to mouse events.  You should use these mouse events instead of the touch events to improve performance.
  • Avoid using mouse move which is fired really, REALLY fast, and can cause lots of extra calculations that are made but go unused between frames.  Instead, do your updates at the framerate by using ENTER_FRAME
  • In certain areas where performance is super-important, consider using callbacks rather than events. Event objects have to be created and propagated, which is expensive.
  • If you’re listening to an object that is deeply-nested in the display list, stop its propagation
  • Bytearray.org/?p=1363 – A whitepaper called “Optimizing Performance for the ADOBE® FLASH® PLATFORM” (attached), this is the single greatest resource for performance tweaks I’ve ever come across.  It validates a lot of the techniques I’m already applying for game development, and points out a few others to consider.

All in all, the 1st annual FITC SF was a resounding success, and you can bet I’ll be back next year!

Videos from Flash Camp San Francisco

I had the pleasure of visiting Adobe’s San Francisco office for Flash Camp a couple weeks back. Coming just on the heels of Apple’s big 3.3.1 announcement, it was perfect timing to hear Adobe’s reaction directly from Adobe. All of the videos are posted online on Adobe TV, but to save you some time, here are my Cliff’s notes:

  • Open Discussion and Q&Q with David Wahdwani – Hear the first reaction directly from the head of the Flash Platform on Apple’s move
  • What’s new in Flash CS5 – Nothing new if you’ve been paying attention, lots new if you haven’t
  • Using Flash Builder 4 with CS5 – “You can edit your code in Flash Builder! It will ask you if you want to edit your code in Flash Builder!”
  • Flash Player 10.1 Internals – Must-see for devs, excellent talk about how the player handles low-memory situations and how to develop for them (think: mobile)
  • Flash Build 4 Tips and Tricks – For devs only really, but there’s definitely a couple tidbits worth noting (like keyboard shortcuts!)
  • TV & Mobile Design Challenges & Insights – “Make text and hit areas bigger” But also gives some concrete recommendations
  • Desktop and Mobile Development with Adobe Air – Adobe officially announced the AIR2 Beta for Android during this preso, talked about what it can do, very exciting
  • Introduction to Multi-touch in Flash Player 10.1 – Excellent primer to get you thinking about how to create multi-touch interfaces with Flash on Android
  • Developer Tips and Tricks for Targeting the Flash Platform – Mostly common sense techniques that good developers shouldn’t be news to any decent developer
  • Advanced Text Layout with Flash CS5 – I didn’t see this session, but the new text layout features are very impressive