Setting Up Starling Framework with FlashDevelop

Are you using FlashDevelop and want to get start using Starling Framework? Here’s a quick tip how to setup your first Starling project!

Note: I’m using the latest FlashDevelop4 RC-1

  • Installed the Flex SDK. I install the latest Flex SDK 4.5.1
  • Make sure you have download player playerglobal.swc here and add it to your Flex SDK folder ({flex_sdk_folder}\frameworks\libs\player\11.0)
  • Download the Starling Framework. You can get it from github or download from Starling website
  • Create a new AS3 project.
  • On Project Property, change output Flash Platform to version 11.0
  • On project property, add -swf-version=13 into additional compiler options
  • Add Starling folder ({starling_folder}\starling\src\) as ClassPaths
  • Create a new Class (just named it Screen1 or any name…) and extends it from class Starling’s Sprite (starling.display.Sprite). So far leave it empty:
package
{
	import starling.display.Sprite;

	/**
	 * Dummy Starling Sprite
	 * @author Abiyasa
	 */
	public class Screen1 extends Sprite
	{

		public function Screen1()
		{
			super();
		}

	}

}
  • Modify your Main.as to add Starling object:
package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import starling.core.Starling;

	/**
	 * ...
	 * @author Abiyasa
	 */
	public class Main extends Sprite
	{
		private var _starling:Starling;

		public function Main():void
		{
			super();

			this.addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
		}

		private function init(e:Event = null):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);

			_starling = new Starling(Screen1, this.stage);
			_starling.start();
		}

	}

}
  • If you compile your project now, you’ll get 2 error messages:

C:\dev\starling\starling\src\starling\events\TouchMarker.as(22): col: 9: Error: unable to resolve ‘media/textures/touch_marker.png’ for transcoding
C:\dev\starling\starling\src\starling\events\TouchMarker.as(22): col: 9: Error: Unable to transcode media/textures/touch_marker.png.

  • The starling framework is trying to get media folder, which is available at {starling_folder}\starling\media\. Unfortunately, you cannot have linked folder on FlashDevelop, so what I did is to copy the folder media to {starling_folder}\starling\src\starling\events\. Note: please let me know if you know better solution 😉
  • Now compile your project! Everything should be OK and an empty blank screen will be displayed.
  • Empty screen is boring, so let’s add something to our screen. Modify our Screen1:
package
{
	import starling.display.Quad;
	import starling.display.Sprite;
	import starling.events.Event;
	import starling.text.TextField;
	import starling.utils.VAlign;
	import starling.utils.HAlign;

	/**
	 * ...
	 * @author Abiyasa
	 */
	public class Screen1 extends Sprite
	{
		protected var _box:Sprite;

		public function Screen1()
		{
			super();
			this.addEventListener(Event.ADDED_TO_STAGE, init);
		}

		protected function init(event:Event):void
		{
			this.removeEventListener(Event.ADDED_TO_STAGE, init);

			createBox();
		}

		protected function createBox():void
		{
			// create box sprite
			_box = new Sprite();

			// create quad (box shape)
			var q:Quad = new Quad(128, 128, 0x009ee1);
			_box.addChild(q);

			// add text
			var text:TextField = new TextField(100, 100, "Hello World", "Verdana", 16, 0xFFFFFF);
			text.vAlign = VAlign.TOP;
			text.hAlign = HAlign.LEFT;
			text.x = 10;
			text.y = 10;
			_box.addChild(text);

			this.addChild(_box);

			_box.x = 100;
			_box.y = 100;
		}
	}

}
Hello Starling

Hello Starling

Bonus: Starling with animation. source code included

Setting up FlashDevelop 4 and Away3D 4

I love to try new toys. By the time this blog is posted, both FlashDevelop4 and Away3D 4 are in beta version, and so does Flash Player 11. I really can’t wait until we have Flash player 11 or AIR 3 on desktop and mobile device 🙂

Here’s what I’ve done to setup FlashDevelop 4 beta with Away3D 4 (assumming that FlashDevelop4 and Flex SDK 4.5.1 have been installed):

Edit (July 2013): This tutorial has been updated for FlashDevelop 4.4.x, Flash Player 11.3, and Away3D 4.1.4. Continue reading

Compiling Flex 4.5 with FlashDevelop 3.3.4

Flex 4.5 has been released! Yes, the release version (4.5.0.20967) has been available since several days ago, so go download it now 😉

I was happy when I got this SDK. Finally, I can replace all those old MX components with new shiny Spark ones. But when I tried to compile, I got this error:

Error: unable to open ‘libs/player/10.1/playerglobal.swc’

Apparently, Flex 4.5 SDK need to be targeted to Flash Player 10.2. No problem, I’ll change on my project settings.

Select Flash Player 10.2... Wait, what?

This is a problem if you’re using FlashDevelop 3.3.4. There is no Fash Player 10.2 on Platform Target. But don’t panic! This can be easily handled by adding 2 additional compiler parameters:

-swf-version=11

-target-player=10.2

You can add them on Project > Properties, specifically on tab Compiler Options. Add those parameters on Additional Compiler Options:

Don’t forget to click OK and Apply. Now, compiling your project using Flex 4.5 should not be a problem anymore.

Enjoy!

Setting Up Metasequoia Plugin SDK

I’m currently making a 3D Flash game using Away3D. For 3D modeling and animation, I use Metasequoia with additional plugin called Keynote. They’re really great tools although at the beginning I had problem with the workflow.

My workflow was like:

  1. Create 3D model and animation using Metaseq and Keynote
  2. Save manually every animation frame as MQO file
  3. I create my own tool using Adobe AIR. This tool loads all MQO files and combine them into a XML file
  4. Away3D (Flash) loads MQO and XML file and convert them into vertex animation

The process #2 and #3 were very time consuming. So I decided to learn Blender. I was hoping I could export the animation into MD2 file directly from Blender file (shorter workflow).

It wasn’t the right decision for me. Learning Blender was so hard and frustating. Strangely, it’s not my first time learning Blender. I already did this several times and always forget everything once my project was done. This time, I tried the new Blender 2.5 beta, which they say, have better and intuitive UI.

There were a lot of hair pulling moments, problems with the UI, always fail to setup rigging for animation, confusing documentation, and there was no working MD2 exporter.

I know Blender is a good tool, in fact that there’s a lot of games and movies done using Blender, but this tool is just not for me.

So I switched back to Metaseq and dare myself to create Metaseq plugin. Yes, you can create your own Metaseq plugin. You can download Metaseq Plugin SDK for free and use Visual C++ to create the DLL files.

Milk Carton Boy, using Metasequoia and Keynote

The instruction was in Japanese and still using Visual Studio 2002 or 2008. Luckily, I managed to make it work using Visual Studio 2010 Express Edition on my Windows 7. Here’s what I did (can’t remember precisely.. sorry):

  • Install Visual Studio 2010 Express Edition C++
  • Install the latest Windows SDK, Windows SDK 7 & .Net Framework 4, version 7.1
  • Install the latest WTL library. I use the latest one, WTL81_9127. Extract them manually.
  • Download the latest Metaseq SDK ( mqsdk249c.zip) and extract the file.
  • Import MQSDK workspace file as VS2010 Solution file
  • Add WTL location to C++ include directory
  • Try to compile one of the project.
  • Copy the dll from release folder to metaseq plugin folder and test it

In the end, I managed make a simple plugin 🙂 It reads Keynote animation data and export them into my custom XML data. I had fun and realized that it’s been 2 years since the last time I am using C++.

Note: Only the non-shareware version of Metasequoia can use plugin. The shareware one does not. But it’s quite affordable, only $45. I could imagine if you use Blender, you could spend that much money for books and tutorial DVDs.

Note #2: You can download the source code of my exporter plugin here: http://abiyasa.com/lab/away3d/mqoplugins/mqoPlugins.zip (around 54K). I use Keynote API (included if you download Keynote plugin) and use the example (ExportXS) as the basic for my plugins. Feel free to ask me if things are not clear 😉

How to Use Flex SDK 4.5 Hero with FlashDevelop

If you’re a Flex developer and want to try Flex 4.5 Hero with Android device, then this post might help you to get started 😉
You might also have a look at my previous post about creating Adobe AIR app for Android using AS 3.0. It might help you to setup some parts like Android SDK and digital certificates, also if you don’t want to use Flex framework and want to use pure AS3 solution.

Before you start, you can always download the whole project and source code of this post from here.

Continue reading