Flash/Flex: Keep Calm and Carry On

source: Wikipedia

Keep calm and carry on.ย That was NOT my reaction when I read Adobe news about Flash Player for mobile. And then came another bad news about Flex SDKย on the following day.

It was difficult for me. I was sad and a bit broken hearted. It’s even harder if you are surrounded by Flash-haters. It take times for me to recover. But this makes me realize that how much I (and probably other programmers) really love Flash platform.

I started playing with Flash since it was Flash 5. Then came Flash MX 2004 with ActionScript 2.0, and then AS3.0 which I like most. I’ve tried many things like JavaScript & even VBScript, not to mention other languages such as Pascal, C/C++, C#. After a quite long journey, I find Flash/Flex + AS3.0 fits me for making games.

Technology keeps on changing and getting better. Unfortunately, HTML5 isn’t ready and mature yet for game development. There are many things HTML5 has to catch up with. Don’t get me wrong, I think HTML5 has potential. In fact, I recommend you to start learning things like WebGL or trying Javascript-based frameworks.

But despite what people say, I think Flash will NOT die in the next 2-3 years. In fact, if you’re a game developer, this is the best time to use Flash. Finally Adobe starts focusing more in game development. There will be many exciting features ahead. Stage3D is still new and we haven’t seen the best things out of it yet. Molehill2, Starling/ND2D, concurrency, Flash Player 12, fantastics Flash-based 3D or game engines, and many more!

It’s also too early to say that this is the end of Flex. Spoon foundation haven’t start something big yet but I’d like to be optimist. By giving Flex framework governance to the open source foundation, Flex future and roadmap can be deciced independently from Adobe’s business or political agenda ๐Ÿ˜‰ Isn’t that great?

So don’t panic, don’t rush. We stil have enough time, either to switch to HTML/JS/CSS, finish your Flash-based game engine, or do other stuff. No one knows what the future will be. Take your time for getting angry or sad, but after that, clear your head and keep your chin up. It might take 2 years (or even more) until HTML5 is good enough and able to catch up everything that Flash can do TODAY. Meanwhile, Flash is still here and keeps evolving.

So carry on, let’s code better Flash games or Flex RIA ๐Ÿ˜‰

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

Exporting Metaseq to Away3d4

By the time I wrote this post, Away3D4 was still in alpha version. Unlike Away3D 3.X, there was no Metaseq parser/loader available ๐Ÿ™ That’s not a problem since we can export MQO 3D model to OBJ using Metaseq itself. The problem is the export settings can be tricky and take some trials-and-errors to get it right.

Here’s what I did to export my MQO model to OBJ:

  • It’s better that you remove unnecessary layers like bone and anchor. Save your model as other file and remove those unnecessary layers.
  • Leave the size to 1.0
  • Away3D use different axis than Metaseq, we need to convert our module axis.Choose the axis to POV-RAY, this is the one that compatible with Away3D
  • Select the UV mapping and also select Invert V
  • Export Normal Vector and Grouping
  • You can export Material Library, which means Metaseq will export OBJ and MTL file. Since I prefer to embed my textures inside my SWF file, I uncheck this options and will assign the textures/materials later using ActionScript.
Export settings to OBJ

My export settings

If you have Flash Player 11 installed on your browser, you can click the image below to see the demo of loading OBJ exported for MQO.

Download the source code hereย (including MQO, OBJ, and FlashDevelop 4 project files)

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

Blog Moved!

This is my new blog address (http://www.abiyasa.com/blog), moved from my old one at http://www.abiamy.com/abiyasablogs. I have to move it because I just change my webhosting server.

Actually, my WordPress Blog got hacked around mid of June. I notice it from Google Analytics report that my blog page views dropped to almost zero in just 2 weeks. I was too busy to act quickly and by the time I realized it, my Blog was not accesable at all.

The last time I access my Blog was about 3 weeks ago, was trying to upgrade my WordPress to 3.2 from 3.1.x. However, I couldn’t do it since I was using Yahoo for my webhosting (shame on me for using Yahoo Webhosting ๐Ÿ˜ ). The new WordPress requires mySQL 5 while Yahoo only supports mySQL 4.

I’ve been planning to move my websites from Yahoo since 1-2 years ago so I thought like ‘this is it!’. So yesterday, I just move my Portfolio (http://www.abiyasa.com) and my Blog from Yahoo.

Almost everything from the old blog are availble on my new domain, abiyasa.com. There might be themes changing or some broken images. I’m still working on it and sorry for the inconvenience.

Stay tune ๐Ÿ™‚