Zynga release PlayScript, a C# 5/ActionScript hybrid that targets the mono runtime

The project is currently up on Github.

PlayscriptLogo

 

 

 

 

 

 

I will let them describe it in their own words:

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 Studio MonoTouch and Mono for Android platforms. 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 implement the full Flash display system.

And:

Features:

Native Performance

  • Using “unsafe” code.
  • Direct interop with native code (Cocos2D-X, other C++ based engines such as Page44, etc).
  • Optimized compiler for JavaScript generation.
  • Optional full C++ target with minimal app size and startup overhead.

Advanced Tools Support

  • Complete tool support including Syntax Highlighting and intellisense in the MonoDevelop IDE.
  • Source Debugging on all platforms (FlashBuilder for Flash).
  • Fast Release mode compiles and rapid iteration.

Full Platform API’s

  • Complete iOS platform API via Xamarin MonoTouch and Mono for Android
  • Complete Windows/MacOSX API’s.
  • Complete integration with UI builder (iOS), and Android GUI builder via Xamarin Studio.

Differences between PlayScript and ActionScript

  • PlayScript supports most features of C# 5.
  • PlayScript requires semicolons after all statements.
  • PlayScript uses block scoping for variables.
  • PlayScript requires breaks in switch statements.
  • PlayScript supports generics using the .<> syntax introduced in AS3 with the normal C# feature set.
  • PlayScript supports properties using the “property” keyword with syntax similar to C#.
  • PlayScript supports indexers and operator overloads using the “indexer” and “operator” keywords.
  • PlayScript implements AS3 namespaces by converting them to .NET internal.

Differences between PlayScript and CSharp

  • PlayScript requires the use of the “overload” keyword on addtional overload methods (allows more readable JavaScript code by only mangling overload method names).
  • PlayScript does not support using blocks.
  • PlayScript does not support checked, unchecked.
  • PlayScript does not “presently” support unsafe code (though this will be added in the future). Currently unsafe code can be added to mobile projects via C#.
  • In PlayScript you may not directly access the base properties of Object (ToString(), GetType(), GetHashCode()) unless you cast an objet to a System.Object. Doing this however will make your code incompatible with the C++ or JavaScript target backends.

 

The provided the following example 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  #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;  }

Very interesting. So basically they are making a HaXe like cross platform tool based on a hybrid of ActionScript and C#, targeting existing Stage3D libraries.

News Programming Programming


Scroll to Top