Getting Started With Starling Development

 

Here comes my first mini tutorial on how to get started with Starling development. I'll focus on the project setup.

 

Downloads
Download and install Flash Player 11 RC1 debugger version.
Download the Adobe AIR3 RC1 SDK
(No need to download the playerglobal.swc, it's included in the AIR SDK)
Download the Starling files from the Starling website.

 

Setting up your SDK
Copy your flex 4.5.1 SDK and override the resulting copy it with AIR3 RC1 SDK (on MacOS, use the ditto command to do so). Rename it something like "4.5.1_AIR3_RC1" and then add the newly created SDK to FlashBuilder's framework list.

 

Building the Starling library
Create a new Flex Library project, name it "StarlingLib", and choose our new SDK. No need to add AIR libraries.
Add -swf-version=13 to your Additional compiler arguments, and target player 11-0-0.
Using the PrimaryFeathers folder you downloaded, copy the com directory, the starling directory, and the media directory to your project SRC folder. 
You should now have StarlingLib.swc in your bin folder.

 

Creating a new project
Create a new ActionScript (non mobile) project (for either AIR/desktop or FlashPlayer/web) and add -swf-version=13 to your Additional compiler arguments.

If making a Flash Player based content add "params.wmode="direct";" to your html template (line 49, for instance).
If making desktop AIR application, I guess you need to set <rendermode>GPU</rendermode> in your descriptor file (still have to check that).

Add the StarlingLib.swc file, or the whole StarlingLib project, to your LibraryPath.

You're ready to go. :)

Now, let's write the sample code included in the starling documentation:

Create a new Game class

 

package
{
	import starling.display.Quad;
	import starling.display.Sprite;
	import starling.events.Event;
	public class Game extends Sprite
	{
		private var q:Quad;
		public function Game()
		{
			addEventListener(Event.ADDED_TO_STAGE, onAdded);
		}
		private function onAdded ( e:Event ):void
		{
			q = new Quad(200, 200);
			q.setVertexColor(0, 0x000000);
			q.setVertexColor(1, 0xAA0000);
			q.setVertexColor(2, 0x00FF00);
			q.setVertexColor(3, 0x0000FF);
			addChild ( q );
		}
	}
}

And finally, modify your main class as follows:

package
{
	import flash.display.Sprite;
 
	import starling.core.Starling;
	import starling.display.Image;
	import starling.textures.Texture;
 
	public class StarlingTest extends Sprite
	{
 
		private var mStarling:Starling;
 
		public function StarlingTest()
		{
 
			// create our Starling instance
			mStarling = new Starling(Game, stage);
 
			// set anti-aliasing (higher the better quality but slower performance)
			mStarling.antiAliasing = 1;
 
			// start it!
			mStarling.start();
 
		}
	}
}

 

Publish, and you should now see a multicolor square on you stage.

Have fun !

 

Anonymous (not verified) on September 21st 2011

How about using it on Flex project that use MXML and AS3 instead of Actionscript project? I love to see how it works.