Mar 9 2010

BulkLoader – managing multiple loadings in AS3

One of the most common tasks in game development is the assets loading process. You have two options: 1) ship your game as a single 45Mb SWF file filled with sweet and compressed-to-the-bones images/sounds or 2) load all those assets separately and on demand.

Sometimes the first option is your best shot, but for casual online games the second one is more suitable. Multiple loadings in AS3 can be a pain, because there are several file types to load (wave, JPG, mp3, GIF, swf, etc) and there is no single way to load them all.

So far my best approach to solve this problem is called BulkLoader, a library for managing multiple loadings with AS3. It is licensed under the MIT License and has amazing features:

  • Connection pooling.
  • Unified interface for different loading types.
  • Unified progress notification.
  • Events for individual items and as groups.
  • Priority
  • Stop and resuming individually as well as in bulk.
  • Cache management.
  • Statistics about loading (latency, speed, average speed).
  • Various kinds on progress indication: ratio (items loaded / items to load), bytes , and weighted percentage.
  • Configurable number of retries.
  • Configurable logging.
  • Various assest types (XML, NetStreams, Swfs, Images, Sound, Text Files)

Design goals:

  • Minimal imports.
  • Few method to learn.
  • Consistent interface, regardless of content type.

BulkLoader gracefully handles progress notification in these use cases:

  • Few connections to open: bytes total can be used instantly.
  • Many connections opened: progress by ratio
  • Many connections opened for data of widely varying sizes: progress by weight.

One of the things I like the most is that this project was created by a Brazilian fellow named Arthur Debert :) . Thanks for this great tool!


Feb 3 2010

OnePress Community

I see lots of open source projetcs using Worpress as a blog platform, phpBB as a forum solution and Mediawiki as a wiki. I like them all, but maintaining them separately with no integrations is a pain. It's great when you register to a website and you can use the same fresh new account to comment on the blog, reply to a forum thread and/or contribute to a wiki page.

Excluding the wiki part, there is a tool that makes it all possible. OnePress is an integrated website and forum solution. It is, simply, a WordPress theme to serve as the foundation and framework for your web site and online  community.

Some of it´s cool features:

  • Seamless integration with phpBB, complete with unified login and widgets to display forum posts on site.
  • Widgetized WordPress layout with drag and drop interface to quickly build site.
  • Professional featured content widgets to display important posts with prominence.
  • Easy to use backend enhancements for editing OnePress widget content.
  • Highly optimized page rendering process for optimal performance.
  • Built with WordPress 2.7 and child themes in mind.  Flexible hook system for full theme customization.

Oct 18 2009

Simple and powerful intranet

These days I was looking for intranet solutions and I luckily found Open Atrium, an intranet in a box that has group spaces to allow different teams to have their own conversations.

OpenAtrium is built on top of Drupal, has a nice design and a useful set of features:

  • Blog: A classic blog for each group that has commenting, file attachments on both the post and comments, and granular notifications.
  • Calendar: A calendar that lets you quickly add events, suck in iCal and other calendar feeds, and support single or multi-day events.
  • Group Dashboard: Mini widgets give you a snapshot of all the activity happening across your groups.
  • Documents: A simple online handbook that lets you collaborate on documents, store and compare revisions, attach files, and once you're done print out the final copy.
  • Shoutbox: Kind of like a private twitter, the shoutbox lets you share short messages, links, and information with just the people in your group.
  • Case Tracker: A full ticketing system that lets you assign to do's and create unlimited projects within each of your groups. The case tracker also lets you classify the to do, give it a priority, and manage its status.

For small companies, it is an efficient tool to create/maintain an intranet.


Jun 3 2009

PHP and PDF in pure Javascript

Javacript is the very first base stone concerning web 2.0. In the past, I always heard bad things about Javascript, but I guess all of them were said because Javascript was being used by the wrong people, in the wrong place and at the wrong time.

A lot of sites use huge Javacript libs, each one performing nice things, such as HTTP requests, animation effects, generation of RIA content, etc. Javascript is so famous now that several things have been ported to it, such as encryption algorithms.

I have found two of those Javascript ports that can be really useful, specially if you are a PHP developer (just like me): PHP.JS and jsPDF.

PHP.JS is an open source project in which you can use PHP functions client-side, in pure JavaScript. jsPDF is an open-source library for generating PDF documents using nothing but Javascript.


Apr 28 2009

IE6 has already fulfilled its destiny, it’s time to upgrade!

One of the most annoying thing I did during the development of our web projects was to keep our apps running smooth in a wide range of old browsers. Not too many years ago, there was only one "king" in the browser's kingdom: Microsoft Internet Explorer. King is a little bit unappropriated, however on February, 2005, IE 6 was pumping the web engines with a market share of 82.79%, what is a quite impressive number.

Excluding the security problems, the non W3C compliant behavior and other issues, IE6 as the only major browser would be a great deal to all web developers. The existence of  just one browser means few environments to test and few compatibility if/elses. The web-developers burden, however, was far from being released.

In 1996, Opera was first released publicly with version 2.0. Coming next, Apple first released Safari as a public beta on January 7, 2003. Following the flow, in November 9, 2004, Mozilla came up with Firefox 1.0. The last one to join the party was Google Chrome, released as a public beta on September 2, 2008. With the built-in markup madness that HTML allows and with no clear rules for how a browser should behave, the web development became a nightmare.

Luckly things got better and the development of major browsers started to have its foundations over W3C standards and performance worries. Every new version of each browser introduced a set of brand new stuffs, including security improvements and higher Acid scores. Everything would be great, except for one huge problem: IE6, an old and obsolete browser, is still widely used!

That problem drastically increases the complexity of web apps, because developers, in order to ensure the website will look fine, have to workaround all the stupid things IE6 does. As the Wordpress guys usually say, "code is poetry"; in my opinion IE6 compatibility code is classified as a bunch of ugly words within a rhyme. It's time to move on, let IE6 go!

To tell that to your users, a good approach is the ie6 upgrade warning. It is a little script (7.9kb) that displays a warning message politely informing the user to upgrade the browser to a newer version (links to newest IE, Firefox, Opera, Safari, Chrome are provided).

Make the Internet a better place, let old things in the past and move on to the new ones. Upgrade your browser.


Apr 26 2009

Profiling and debugging PHP

Reviewing the code is an important task every programmer must (or should) perform. Sometimes the program you have just coded looks nice and fast, because all the tests you have performed using your well-controlled devel0pment sandbox showed no errors.

Unless you are a god when programming, you may have left some little performance tweaks behind. Most of the time you can replace several method calls with the returned value stored in a variable, or avoiding nested for/whiles, or freeing a result set in order to save some memory, etc. In the end, all those tweaks can make the difference between a smooth user experience and an extremely painful development problem.

If you are a PHP developer, you can use the free PHP Quick Profiler (PQP) to help profiling and debugging your code. No more echoing vars, objects or queries in order to find performance mistakes. Using an automated tool to show you what is going on, you can save a lot of time and ensure your app is stable and fast. I read about PQP at WebAppers these days. They also have a screenshot (below) and a link for a demo.

PHP Profiler

If you want more options for profiling and debugging, I recommend Xdebug, which is a very powerful tool. We have been using it at Decadium for a long time.  Some of the features include stack traces and function traces in error messages (with full parameter display, function/file name and line indications), information about memory allocation and protection for infinite recursions.

Xdebug is also free and has support for Windows and Linux.