AS3 Random Number Generator

Polygonal Labs has an excellent random number generator.  There is an AS2 and AS3 version and it has much better random numbers tools such as seeds and ranges.

When developing games you often need a PRNG that, once initialized with a seed value, produces always the same sequence of random numbers after it. The Math.rand() function in Flash is a PRNG, but it doesn’t let you define a seed value (I think it’s picked randomly when the swf starts, but there isn’t much information about it) so another solution has to be found.

One of the best PRNGs is the Mersenne Twister algorithm, but in my opinion it’s total overkill for flash games (also slow and difficult to implement). However, after spending some time with google I found an interesting site explaining the implementation of the Park-Miller-Carta PRNG, which belongs to the group of Linear congruential generators (LCGs).


Download & Usage

Park-Miller-Carta Pseudo-Random Number Generator:
AS2 Version
AS3 Version

First define a seed value (default is one) and then call nextInt() to get the next integer value, nextDouble() to get a floating point number between 0..1 and nextIntRange() or nextDoubleRange() to generate numbers within a certain range.

Game Development Common Algorithms /Techniques

Here’s some algorithms and techniques that most game developers should be aware of when developing games for Flash, Director or other gaming tools (primarily 2d or fake 3d).

A* (A Star)*_search_algorithm

Mode 7

Collision Detection

Painter’s Algorithm (papervision/software blitter)’s_algorithm


Isometric Projection aka Axonometric Projection aka Orthographic Projection (essentially lack of true perspective in 3d objects)

Well versed in mathematics such as Trigonometry and Calculus

If you want to make games, math is required. Wiki should only be a starting point. Sometimes the best way to understand something is to implemented it or try to implement it yourself. There are lots of samples and tutorials on the web regarding these but its always good to understand what makes it all work, usually that is math. Right after “42” it is the answer to Life the Universe and Everything.

We will feature another set for primarily 3d games such as quaternions, matrix maps, transformation matrices , 3d projection and more! Over time we hope to have a tutorial for all 2d in flash and 3d techniques in papervision or 3d framework such as OpenGL or DirectX.

Telerik Silverlight Controls

Telerik has created a set of Silverlight controls.  They are always on top of new technology from Microsoft and sometimes it seems like they work there.  Here is a sample room editor that has must a sprinkle of pseudo 3d. One interesting thing about Silverlight is that MS AJAX will be specifically written to work with it.  I am sure there will be other packages but it appears like Microsoft is setting out the developer workflow quickly.
Photo Sharing and Video Hosting at Photobucket  Photo Sharing and Video Hosting at Photobucket

At this point Silverlight doesn’t compare much to Flash and has a long way to go.  The WPF libraries are excellent though and will get lots of following.  The Microsoft developer community is a bit like the Apple consumer in that they pretty much buy into anything that they are fed, so it will have some legs.

Silverlight, the cross platform version of WPF, is great (more on this later after I have delved in further) but it is no Flash.  However, it is eons ahead of their last attempt in Liquid Motion.

On Coding Silverlight vs. Flash9/AS3

I like using C#/XAML to code in Silverlight/WPF over Actionscript3 but AS3 is quite a nice language and it is starting to conform to the Javascript2 spec. I think that Javascript2 might be an underrated candidate for the NBL.   AS3 is also very similar to Java and its clone C# so really good solution developers should be learning and becoming experts at all three.

Tweening Bezier Curves with Tweener AS3

Zeh has posted a great article on using Tweener to animate along a Bezier.  There is even a papervision3d sample.  Tweener has been a good choice for papervision3d animation due to its flexibility to be able to easily handle z and custom params.Photo Sharing and Video Hosting at Photobucket

This is excellent for game development or pathing in game systems.  The sample in papervision is a set of cones that the path can be set around.  For custom scripted sequences and triggered events this is exactly what is needed. Things like flying through cities, vehicles, transitions, recording replays etc.

I am blown away by this as its probably the most useful and cool demo I have seen yet. Check it out Download the source here (Flash CS3, AS3). 

I will give this project 6-8months before its a full blown papervision3D scene editor in flash. 

Flash CS3 and Setting up AS3 with Libraries like Papervision3D

Photo Sharing and Video Hosting at PhotobucketThe new Flash CS3 application is excellent.  The new menu and pallette system they have build in is very quick and non-intrusive.  The general UI is very responsive in Flash and Dreamweaver.  In version 8 and other big IDEs out there things have been slowing down, but this release by Adobe things have really sped up.  However if you have been developing Papervision3D and using flash 9 alpha, FlashDevelop etc you may have a bit of setup to do to use Papervision3D or some of your old kits that are having trouble compiling.

Compiling AS3 with Flash CS3 is pretty simple the default classpath to the ‘flash’ namespace is already set by the application to $(AppConfig)/ActionScript 3.0/Classes.  You can also add your class library path to where papervision3d is located in Edit > Preferences > Actionscript > ActionScript 3.0 Settings… (button). I keep mine in [drive]\Projects\FLASH\classpath\as3\. 

FlashDevelop/Flash9 Alpha AS3 Users

One problem is that if you have been using the alpha flash 9 and used FlashDevelop or another IDE you might have some classes to remove from your class path before you can jump right in with Flash CS3.  These would be anything in the ‘flash’ folder in your classpath and probably some type classes in the root such as (intrinsic classes you may have added to complile to AS3 or code completion like in FlashDevelop).

Best Solution

The best solution if you do not want to clean that manually is setup a new classpath folder and then move new AS3 libraries in there. Or, you could setup a new folder and keep the existing classpath until your projects are swtiched over. I keep a classpath for all versions I currently support in my development.




These paths can be added to your Flash IDE, your external flash actionscript IDE like FlashDevelop or other compilers that may come along now that Flex SDK is opensource.

PSD to XAML Converter

Photo Sharing and Video Hosting at Photobucketflowlabs has a PSD to XAML converter. 

Psd2Xaml (with a splash of swf)

Simple, free, open-source tool for converting Photoshop .PSD files to XAML. Also supports limited SWF conversion to XAML.
This project is a by-product of the development of PaintLab, a node-based paint application.
Read more about the underlying PSD parser in this article:


Drag’n’drop PSD or SWF files to the application, and it will create XAML files in the same directory but with the extension xaml instead of psd. The individual layers’ bitmaps are saved in a subdirectory with the same name as the output .xaml file plus “_Bitmaps”.

Example: “Test.psd” is converted to”Test.xaml” and a new folder with the name “Test.xaml_Bitmaps” will be created, containing the bitmaps.


Application: (233 kb)
Source: (226 kb)
Test media: Tiger.swf (16 kb) (psd, 989 kb)

It’s Gr-r-r-e-eat!!

Best Actionscript Animation Packages (AS3)

There are many ways to animate in Flash and the best way is always scripting, or I mean code in AS3.  Flash has grown up quite a bit and now has a very fun coding language in AS3, when programming games or animations scripting is the way to go. You can even do stuff like make a SMTP server/client using mime in it, ok maybe more useful is a binary socket asset loader.

The default mx.transitions classes in AS2 were good, there are much better filter and transition tools now in AS3 but also a bit more bulky than needed and many good Photo Sharing and Video Hosting at Photobucketanimation kits have come along that help people animate with script.  This can be great for team development when architecture is set within everyone’s styles, animation packages for example help to make it easy to have common code so that people can easily understand it. It can be bad when it comes to flash development when you open other’s work if they do not use  at least some standard kits or conventions.

There are a few really excellent animation packages that you should know about.

Photo Sharing and Video Hosting at PhotobucketThe best AS3 animation packages

  1. Animation Package (AS3 kit here)
  2. Tweener (samples here like this papervision3d sample for 3d tweening)
  3. Fusekit and ZigoEngine from MosesSupposes (updated as of late march early april development has started on an AS3 version – not sure of release so its sitting at third)

*All* of these kits allow for total control in a push mechanism to just push animation events onto clips in a dynamic way.  This gives maximum flexibilty for team development and easily changed transitions, or completely random movements.

Fuse has some nice stuff in the works for ColorFX, SoundFX, and even a PaperFX controller for papervision3D.