Stroep

Just a collection of random works – Mark Knol

Multi platform fun (4)

April 7th, 2013, under Other.

haxe-flashMy life as Flashdeveloper changed.
For some Flash is already dead since ages, but for me it’s an important part of my fulltime job. As Flashdeveloper, I’d love to point to the fact that Flash worked from browser x to browser z, but nowadays Flash is not that widely supported anymore. On desktop it was/is, but we cannot forget mobile and tablets these days. For a long time I thought that it would not change th├ít soon, but my mindset is changed. New challenges!

I got the overall feeling that our jobs as Flashdevelopers are changing, we are expected to create websites/games that work everywhere. The client requests and expectations have changed too. One language, all devices, same appearance. Its the developers dream, but its also an illusion. It would be so nice to just build only one product, which would be compatible on all devices, all old and newer browsers. In the real world of web development, a nightmare has born, because this is the reality: device XX version X.XX with browser X version X.XX does not support feature XX, but feature XX works unexpected, and scaling is messed up after doing XX. That is my experience on my first mobile project. I don’t like to complain, but mobile browsers are also messed up. The client does not care about this and the end-user doesn’t either, so that makes creating very rich web experiences complicated sometimes.

I see lots of Flash coders learn other stuff, some go native mobile, go HTML5, or do hardcore coding with shaders and stuff. So time to expand the view! I’m not that up-to-date with mobile and apps. I never gave myself time to actually create mobile apps, it looks like a complete other world compared to ‘normal’ and the interactive experience sites I’ve created before. I dread to learn Objective C or Java *only* to create an platform specific application. No one can look into the future, but I hope over time web apps will survive in a way. I also hope mobile browsers will become more solid, because I like the web more than apps.

In the meanwhile

.. I start to like Haxe. Haxe is perfect for the transition, it brings several worlds more close to each other. It’s a code language with very nice features, when compared to actionscript 3 (which I personally really love). For my first commercial game at MediaMonks we used the Flambe framework, a mobile browser game. Flambe renders very well to both Flash and HTML5. For Flash it is using Stage3d, for HTML it draws on canvas, WebGL is coming soon too. You can still use Flash to create animations, these can be converted using Flump. This is a tool to suck the sprites+animations out of Flash. Flambe has nice integration of Flump exported animation. Yes, the workflow is a few steps back, but since you can use Flash IDE as tool, its doable and fun! (Oh and with fun I mean to create the game using this new workflow, not to debug on all devices; that sucks badly). Flambe is a very good Haxe framework for HTML+Flash, so if you don’t know it yet, check it out. My second project with Haxe/Flambe, tweetfighter.nl, is a ‘game’ where you can fight with social data, it works on lots of new mobile devices.

There is still a lot to learn about Haxe, that’s the exciting part :) You can use Haxe to target HTML and Flash like I did, but you can also target PHP or nodeJS, or if you like to target mobile apps using c++, thats all possible. I have never used nodeJS or c++, so that makes me wonder if it makes development more easy or difficult. But I really like the feeling I’m very close to lots of unknown platforms with the same toolset. The language itself is also very nice, and the upcoming Haxe 3 has neat new features. It would be nice if Haxe gets a little bit more attention, since the idea is pretty good.

“Flash is just a platform that you can target if you wish”
(quote by Nicolas Cannasse, founder of Haxe)

HTML5 (in modern environments) works pretty good. In the early days, you had to build a HTML alternative for Flash. Now, Flash is used a lot as fallback for HTML5. Since Haxe, we can target HTML and Flash at the same time, so that give the choice of technology per platform (like Flash works better on desktop, HTML better on mobile). At first it looks like Haxe was very limited in control, but with a bit knowledge and even when you use a frameworks like NME or Flambe, you can still build own custom components and create professional applications/games. You have more control then you would think, conditional compilation is very useful (also search for haxe magic). So the results of the projects are very promising!

I’m very proud of both of my projects at MediaMonks, since I had to learn a lot of new things in a short amount of time. That said, I’m very interested in creating games, this is a new world and gives me more challenges as developer. It makes me want to create custom tools and useful classes, optimize workflow, relearn about performance optimization and follow slightly other type of developers with cool interesting approaches. I already met some nice Haxe and game developers. I will probably share related stuff on twitter (@mknol) or via this blog, so keep in touch!



4 responses to “Multi platform fun”

  1. Mark Fuqua says:

    Give Adobe Air a try. It targets both IOS and Android…it allows for that same experience you were used to, targeted at mobile…excepting Windows phones.

    I’ve even had good success with business app written with Flex running in Air. There are limitations (Flex, even the mobile version) is pretty heavy, but for quickly hooking up to a company’s data to view and manipulate it, Flex in Air is pretty freaking cool.

    I wouldn’t use that approach to build a consumer app for the app market, but for custom business applications, it is about perfect.

  2. miniml says:

    I think haxe is cool, but it kind of depends on a project. My feeling is is you aim for games than i would not like to write code that will be converted to as3, which will be converted to bytecode which will be then interpreted in vm. or in ios case one more conversion after bytecode would be needed if you target air.

  3. Mark Knol says:

    @Mark Fuqua Thanks for your reply! With Flambe, it’s easy to target Android and iOS, this is done via AIR (should work out-of-the-box). I have tried to test my game to compile for Android (using air), performance is way better that in the android browsers. So it’s already possible with Flambe.

    However I heard with NME, you can target to native code for Android /iOS, so skips the AIR-step, which is (in the end) extra conversion. I wonder how much difference that will make.

    @miniml I understand your concern, I had the same. Before I used haxe I even thought the same; converted code cannot be fast. However I have the idea that the compiled code is pretty good. For example, I checked the javascript output sources, it looks well structured. Yes there is probably some overhead, but from what I’ve read its already pretty optimized code. Maybe a haxe expert has some numbers about differences in performance/loss. If you need to build a separate flash and html version to have maximum reach within mobile and desktop browsers, than haxe still could be a good choice to consider.

  4. Edease says:

    Interesting read,

    I suppose you’ve already have heard of stageXL for Dart by now. You can code the way you are used to in as3 (almost) and it spits out very decent Javascript!

    Check it out at http://www.stagexl.org/
    Nice Site btw :)

Say something interesting

Please link to code from an external resource, like gist.github.com.