And another, physics engine. this one looks pretty good.

After playing with FOAM for an evening, I found this engine to be a fairly easy to work with. I did run into a problem where the FOAM Vector class conflicted with the built in Flash Vector class. The Flash Vector class was added in CS4, FOAM obviously was written before this.

The problem could have been circumvented by carefully qualifying package names. This would have been an elegant and intelligent solution. In stead I decided for the more ham fisted approach of changing all instances of the name Vector to VectorPoint.

I just opened all of the files in the org.generalrelativity.foam and subpackages and did a find and replace on each file, replacing Vector for VectorPoint. Don’t forget to change the file name of to Compiler errors will often point out any spots where you missed an instance of the name.

The generalrelativity blog posts some FOAM renderers. This are useful files. I packaged them in the org.generalrealtivity.foam.view package. It seemed like a logical place to store them. Don’t forget to change the package declaration at the top of each of these files.

FOAM seems pretty easy to use. Unlike Box2d it uses pixels and stage coordinates to position elements on the stage which made it more intuitive to use. The property names seem very intuitive also. Moving objects look to all be built off the SimpleParticle class. Which has obvious properties like x and y to work with. So, creating any Object that inherits from SimpleParticle, you can position it by setting it’s x and y to stage coordinates. Pretty simple. Almost like working with regular MovieClips.

I did notice that fast moving objects could pass through another object. I assume this is caused when the velocity is great enough that the object moves past the interposing object without intersecting.

iPhone Apps with CS5

Lee Brimelow has a great video about creating apps for the iPhone with CS5. This is is just a preliminary video showing a prerelease version of Flash CS5. The process may change in the final release, but it gives a good idea of what is going on and what kind of performance you can expect.
Sounds like it costs $99 per year to become an iPhone developer through Apple. You’ll have to pony up if you are serious about developing iPhone apps.

Here’s a little on someone’s experience creating apps for the iPhone:


SWFObject, if you haven’t heard of it already is a really great little javascript that simplifies the process of embedding your swf files in an html page. This is a huge improvement over the default systems provided Publishing from Flash or Dreamweaver.

The method provided by the Publish settings in Flash and Insert > Media > Flash in Dreamweaver work just fine, but they leave you with a huge Javascript mess in your HTML page. SWFObject provides a clean and organized system that works well and provides a few extra perks.

You can download SWFObject here:

SWFObject is contained in a single small Javascript file. I have been using the latest version (at the time I wrote this it was 2.2) and it seems to work well.

You can write the code for yourself following the documentation on the site listed above. Or use the code generator here:

I had some trouble getting Flash to display 100% width and height. But this was sorted after a short Google search. Turns out the following styles are required:

html, body {
 background-color: #616264;
 overflow: hidden;
#flashcontent {

Note, without overflow:hidden you end up seeing the scroll bars and the page scrolls about 5px. This was very confusing, you would figure that 100% height would make everything the size of the browser rather than a little larger?

ImageStreak Class for AS3

Here’s a new version of the ImageStreak Class written for AS3.

This class loads an image file. Creates a new Bitmap and BitmapData objects. Then it procedes to draw the image one pixel column at a time drawing the current pixel across the image. After it’s finished with the first column it moves on to the next. Until the entire image is drawn.


Lately I’ve been finding that I use the iterator more and more. The Iterator is a design pattern that is used to iterate through the elements in an array. It provides a few features that make it a better choice than the typical loops that you might employ. The core concept is that the Iterator pattern is a class that returns each element in an Array. Forget writing all of those typical tired for loops and move on to a more streamlined pattern based system!

The Iterator provides a few advantages over the standard methods of looping through an Array. The Iterator pattern encapsulates the Array, prevent accidentally modifying the array. By making Iterators to access elements forward, reverse or randomly, accessing elements in the array in these ways becomes as easy as making an instance of any class.

The Iterator is built around three methods, hasNext, next and reset. The hasNext method returns true when there is a next item in the array. The next method increments the index and returns the next item. The reset method resets the index to 0 to start over again.

You might use the Iterator in this way.

var it:Iterator = new Iterator( array );
while( it.hasNext() ) {
	trace( );

The Iterator class itself might look like this:

package com.webdevils.utils {

	public class BasicIterator implements IIterator {
		private var _data:Array;
		private var _index:uint;

		public function BasicIterator( array:Array ) {
			_data = array;
			_index = 0;

		public function reset():void {
			_index = 0;

		public function hasNext():Boolean {
			return Boolean( _index < _data.length );

		public function next():Object {
			return Object( _data[ _index ++  ] );

Flash or Javascript?

Here’s a post about the pros and cons of each. The comments below are interesting.

Many of the discussions I’ve read on this subject always bring up requirement that the Plugin must be installed for Flash to work. I always think, does anyone not have the Flash plugin these days? It seems like it comes with every browser, anyone that wants to watch a video on Youtube is required to upgrade to the latest version of Flash. Who isn’t watching youtube?

I’m sure someone doesn’t have the plugin, or doesn’t have the latest version. Hmmm… they may be hard to find.

Adobe suggests about 80% to 99% market penetration. Of course their numbers may be a little rosy, they have a stake in the issue.

Wikipedia suggests about 95% Did Adobe write that article?

Here’s a link to an article that makes a strong argument for Javascript over Flash. Though, their example site, The Official Ringo Star web site is so weak it counters their argument. The motion is terrible and the rollovers made with Javascript are nothing worth even mentioning.

Of course then it’s off the TheFWA to see what they have on display these days. Looks like every site on display used Flash. After looking at all of these sites it reminded me of the point made in the articles above that, Flash is for complex and 3d animation. I don’t think that quite covers it. I’m seeing sites that are drawing things and mixing video and images with motion in ways that aren’t quite done justice by “3d” or even “complex animation”. Of course all of these sites could be described as complex animation.

Of course for the majority of sites Flash is usually overkill. The difficulty of mixing Flash with a server side framework or CMS is a big downer. So making modern everyday use web sites is also firmly in the Flash camp.

Another con, usually attribute to Flash is the steep learning curve. I’m not 100% behind this argument. It seems to me that HTML and CSS is a pretty hard, mix that with Javascript and I think reaches the same difficulty as Flash and Actioscript. Of course maybe the people writing the articles are think that they already know HTML, CSS and Javascript so it must be easier than learning Flash?

I think for myself I would have to say, when it comes to experimental and cutting edge Flash is out in front. That said I’ve seen some really cool Javascript sites. Here’s a list of good ones (sorry Ringo your site didn’t make this list).

The real idea is to make the right decision Flash or Javascript. Knowing when to choose one or the other is the real skill.

I don’t think I’ll be dumping Flash any time soon, but I will have to brush up on Javascript skills, especially with all of those new CSS3 HTML5 goodies.


Here’s an app I thought up the Firday. I managed to “finish” it up after dinner Friday and and with a few spare hours Saturday. I put finished in quotes, because it’s not really finished. There’s a still a lot to do. I did manage to mock up the basic ideas and get them all working.

So what’s the idea anyway? Anyone can make a user account, login and create a small drawing, and then list all of the drawings that have been created. My idea was to create a sort of Twitter for the visual set. Instead of typing a short message of the moment. You can draw a small picture of the moment, and post it for everyone to view.

The basic functionality works now, but to make this really useful will require more features. At this point you are viewing all of the drawings in the database. The real idea is to show only drawings from people that you feel like seeing.