Pages for playscript repo.
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.
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.
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).
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.
You can download the current PlayScript mono framework binaries here:
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.
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.
Mac:
http://www.mono-project.com/Compiling_Mono_on_OSX
Windows:
http://www.mono-project.com/Compiling_Mono_on_Windows
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.
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.)
Code contributed to this project by Zynga is released under the Apache open source license.
// 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
#if DEBUG
#else
#endif
// 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("http://msdn.microsoft.com");
var urlContents:String = await getStringTask;
return urlContents.Length;
}
Please join the discussion on Google Groups here:
https://groups.google.com/forum/?fromgroups#!forum/playscript