Easy Inheritance & Modularity in Lua

Seeing many flash developers praising Lua-based SDKs like Corona and Gideros that allow us to create mobile games quickly, I couldn’t help trying them myself.

First thing I did was read up some Lua tutorials. The language seems pretty easy to grasp — everything is a table which looks like associative array or a Dictionary in AS3. Good. Until I got to the point where I want to apply/emulate OOP or write code in modular fashion. This is where things become confusing because code examples from Corona and Gideros show you how to shove everything in one big main.lua file. To add even more confusion, different Lua OOP examples show you how to emulate OOP in different ways. And there are things called metatable and metamethods.

After an hour reading the docs and wiki and doing some experiments. I found that it’s really not that hard. Here’s an example of inheritance in one big file.

Continue reading →

How to Use SWC as RSL in Pure AS3 Projects

Using SWC as RSL in Flex projects is a no brainer. Flash Builder and Flex ant task automate a lot of things for your convenience. Unfortunately, that’s not the case with pure AS3 projects. I read somewhere that you can use a special Frame tag and a factory class to load the RSL swf before you instantiate your document class. I tried that but I got mixed results; it didn’t always work in all cases especially when the SWC contains a lot of assets. I might be doing something wrong; I don’t know.

It turned out that you can use a “loader” SWF to load the RSL swf before your main SWFs to achieve the same thing. That left me with one problem, how to get the RSL swf out of the SWC. As we know, SWC is just another compression format, just like zip so any zip expander/extractor will work but manually extracting the SWC is going to be a pain in the @$$ and you’ll have to do it every time you update your SWC. This is where Ant becomes your best friend 😉

In this post, I’ll show you how to do it with Flash Builder & Ant.

Creating Projects

First, we create a new workspace and add build folder to store the published SWFs and then create the projects below:

  1. MyLibs – Flex library project. This is the RSL to be used by AppOne and AppTwo.
  2. AppOne – AS3 project
  3. AppTwo – AS3 project
  4. loader – AS3 project that will load all other SWFs

Then we add a Car class to MyLibs project and compile the project so we have MyLibs.swc in its bin/ folder.

Continue reading →

Bekerja dengan FlashDevelop, Flex SDK, dan Flash

Dalam artikel kali ini saya jelaskan cara bekerja dengan FlashDevelop, Flex SDK, dan Flash CS3/4. Flex SDK saya pakai untuk kompilasi proyek karena jauh lebih cepat daripada compiler bawaan Flash IDE.

Di sini, Flash IDE saya gunakan untuk membuat library berisi objek visual, atau biasa disebut asset library. SWF yg saya buat dengan Flash IDE hanya berisi sedikit kode atau malah nggak ada kode sama sekali. Kode program utama saya buat dengan FlashDevelop dan saya kompilasi dengan Flex compiler.

Ada 2 cara untuk menggabungkan asset library dengan program utama yaitu:

Continue reading →

Bagaimana Menulis Kode yang Bagus

Selama saya berkarir sebagai developer Flash dari taun 2004-an, sudah ribuan baris kode dari puluhan aplikasi Flash yang saya baca. Banyak yang bagus dan gampang dipahami, banyak juga yang njelimet & ruwet mirip pangsit mie. Banyak kasus saya temui waktu saya menginterview pelamar di Trippertlabs dimana pelamar yang portfolionya luar biasa bagus, ternyata kalo nulis kode luar biasa jelek ( kebetulan posisi saya adalah Senior Developer jadi saya selalu kebagian giliran pertama untuk “menyiksa” pelamar 🙂 ).

Untuk keperluan internal Trippertlabs, saya pernah mempublikasikan tulisan berjudul Coding Guidelines for Flash & Flex Developers. Saya pikir ada baiknya kalo artikel itu saya tulis lagi di sini.

Mulai dari yang paling dasar yaitu indentasi.

Continue reading →