Pages for playscript repo.



What is PlayScript?

PlayScript is an open source Adobe ActionScript compatible compiler and Flash compatible runtime that runs in the Mono .NET environment, targeting mobile devices through the Xamarin platform. With a combination of Adobe FlashBuilder for Web and Xamarin Studio for mobile complex large scale cross-mobile-web projects can be developed with full IDE, source debugging and intellisense support on all platforms, with access to the full native mobile API's on the mobile platform.

The PlayScript compiler also targets both C++ and JavaScript (similar to the Haxe compiler) allowing ActionScript code to be run via JavaScript on the Web, or natively on PC and mobile (with some limitations). (NOTE: Presently the JS and C++ targets are at an experimental stage).

In addition to accurate ActionScript language support, the PlayScript compiler also supports a new language - PlayScript - which is derived from both C# and ActionScript. This new language supports all of the features of C#, including generics, properties, events, value types, operator overloading, async programming, linq, while at the same time being upwards compatible with ActionScript. The PlayScript language can be used to target both web and mobile (via Xamarin and JavaScript), and existing Flash code can easily be converted to PlayScript code by simply renaming files from .as to .play, and fixing a few issues related to the stricter syntax and semantics of the PlayScript language.

Finally, the PlayScript runtime supports a full Stage3D compatible implementation of the Flash runtime allowing games that are Stage3D compliant to run with very minor modifications on mobile via the Xamarin/Mono runtime. A subset of the "display" library is implemented to support Stage3D libraries such as Starling, Away3D, and Feathers, though there are no plans at the present time to implement the full Flash display system.

The PlayScript compiler and runtime provides a complete toolset for building and running ActionScript based games on mobile via the Xamarin Mono runtime, on the web via Adobe Flash or JavaScript/HTML5.

How is PlayScript Implemented?

The PlayScript compiler is implemented as an additional front end to the Mono MCS compiler. Installing the PlayScript version of the Mono framework allows you to compile, with the MCS compiler all three langauges: C#, ActionScript, and PlayScript simply by adding files with .cs, .as, and .play file extensions to the MCS command line.

Likewise with the Xamarin Studio IDE, pointing the Xamarin Studio ".NET Frameworks" preferences page selection to the PlayScript Mono framework allows you to simply add .as or .play files to any C# project, and compile them directly into your MonoTouch or Mono for Android project. You can then compile ActionScript or PlayScript code and debug it on the device just as you would any C# code. ActionScript code can directly call C# code, and vice versa.

How is the Stage3D Flash Runtime Implemented?

PlayScript includes two libraries: PlayScript.Dynamic_aot.dll, and pscorlib.dll, which implement the basic flash runtime and Stage3D over OpenGL. Referencing these libraries (or the Monotouch or Mono for Android versions of them) in your project in Xamarin Studio allows you to run existing Flash Stage3D code with no modifications. (NOTE: A stubbed version of the flash "display" library is included, but is non functional except for various functionality in Bitmap, BitmapData, and TextField).

Current Status

The PlayScript and ActionScript compiler front ends are fairly stable at this point (given that they are built on top of the very mature Mono compiler and runtime), but there are still several ActionScript language features that are not fully implemented, and certain constructs that are not parsed or compiled as they are in ActionScript. Work is ongoing to eliminate these last remaining issues and deliver full ActionScript compatibility.

ActionScript support

  1. Dynamic classes are compiled but are not implemented yet.
  2. The [Embed] tag is not yet implemented.
  3. The singleton guard pattern is not supported (using a private parameter to a public constructor).
  4. Static and non static members of the same name are not supported.
  5. Class and package level statements are not supported.
  6. Variety of small bugs which require minor work arounds (these are being eliminated over time).

PlayScript support

  1. Unsafe code is not supported (conflict with the use of the * symbol in ActionScript).
  2. Some issues with multi dimensional arrays.
  3. JavaScript and C++ targets are experimental.

Runtime support

  1. Much work has been done on the Stage3D library support, and full AGAL to HLSL support has been implemented.
  2. Starling and Away3D libraries are functional and most features are supported.
  3. Very little work has been done on net, and other core libraries.

How do I install PlayScript?

You can download the current PlayScript mono framework binaries here:

Mac OSX 0.1.3 (Mono 3.0.9)

Windows Win32 0.1.2 (Mono 3.0.9)

The mono framework folder includes the entire mono SDK, tools, and libraries. To use the framework, you must install Xamarin Studio, and follow the instructions (below) to set the PlayScript mono framework as the default framework.

Building From Source

PlayScript is simply part of the regular Mono build and the MCS compiler build by Mono will compile ActionScript and PlayScript .as and .play files.

See the MONO build instructions below.



Also, the base pscorlib.dll and PlayScript.Dynamic.dll runtime libraries (minus Stage3D support) will be pre-built and added to the GAC gache in the final mono install. To use the "monotouch" or "monomac" or "monoandroid" versions of these libraries, use the included .csproj files in the mcs/class folder in this repository.

How do I use PlayScript from Xamarin Studio?

  1. Build the Mono framework from this repo using the Mono build instructions. Use --prefix=/Users/myname/playscript-mono-inst to install the framework to a reasonable location on your hard disk.
  2. Open Xamarin Studio, and select Preferences..
  3. Select the .NET runtimes tab.
  4. Click the "Add" button, and select the folder where you build the PlayScript mono framework from step 1.
  5. Click the "Set as Default" button.
  6. Exit Xamarin Studio, then restart.

You should now be able to add .as files and .play files to your projects and compile them. Note that you must make sure the file is toggled to compile by selecting the "Properties" panel in Xamarin Studio and setting the "Build Action" to compile.

(NOTE: A modified version of MonoDevelop should be available in the playscript-monodevelop repository that includes full support - including syntax highlighting for both .as and .play files.)


Native Performance

Advanced Tools Support

Full Platform API's

Differences between PlayScript and ActionScript

Differences between PlayScript and CSharp


Code contributed to this project by Zynga is released under the Apache open source license.

Starling Demo

Away3D Demo

PlayScript Sample Code

// Basic types
var b:byte;
var sb:sbyte;
var s:short;
var us:ushort;
var i:int;
var u:uint;
var l:long;
var ul:ulong;
var f:float;
var d:double;

// Conditional compilation

// Fixed arrays
var a:int[] = new int[100];

// Properties
public property MyProperty:int {
   get { return _myInt; }
   set { _myInt = value; }

// Events
public event MyEvent;

// Delegates
public delegate MyDelegate(i:int):void;

// Operators
public static operator - (i:int, j:int):int {

// Indexers
public indexer this (index:int) {
   get { return _a[index]; }
   set { _a[index] = value; }

// Generics
public class Foo.<T> {
    public var _f:T;

    public function foo<T>(v:T):void {

// Async
async function AccessTheWebAsync():Task.<int> 
    var client:HttpClient= new HttpClient();
    var getStringTask:Task.<String> = client.GetStringAsync("");
    var urlContents:String = await getStringTask;
    return urlContents.Length;

PlayScript Google Group

Please join the discussion on Google Groups here:!forum/playscript