Flash notes by Edzis

ActionScript programmer / Flash developer Edgars Simsons on professional stuff

Archive for the ‘ActionScript 3’ Category

3D dice with rounded edges

with 13 comments

3D Dice. Click to view in action

3D dice. Click to view in action

This is a 3D dice I made in FIVe3D. It has rounded edges that animates with rotation to the next score.

A couple of weeks ago I had to add a dice for a game my colleague was developing. Scanning the net did not give any satisfactory results so I set off to make it myself. As I knew there will be vectors only I chose to use this task to check out FIVe3D. After dropping the idea to implement real physics I made the first static dice rather fast -  just a cube with 6 faces and circles on them.  The sharp corners just did not fit the the design requirements. So in a dirty way I squeezed in some extra rectangles and triangles between the 6 faces of the cube what made the corners appear rounded. For the outlines see the image on the side. Sadly this broke the shadows being drawn correctly; I tried to overcome this problem but did not succeed  (but maybe someone else wants to try it out).

Outlines of the cube edges

Outlines of the cube edges

The dice is easily customizable. You can change it’s size, view angle and light effects. The dice’s roll() method accepts a previously chosen target value, but can generate it on random. An event is dispatched after the roll animation has completed. It has a slightly different animation depending on mouse position.

View the example and download project source. Let me know if you find it useful.

Written by edzis

March 13th, 2009 at 3:31 pm

Posted in ActionScript 3

Version 2 of Tree generator in 25 lines of ActionScript

with 4 comments

Sample image of Tree generator 2

25 line Tree generator version 2. Click to view

January 2009 finalists of the 25-Line ActionScript Contest have been announced and sadly my entry is not among them. Therefore, to fulfill my desire of sharing I present you Tree generator 2. And for my fellow coders here is the source. Just a small tip – click on the stage to start a new tree.

This time it is more math than flash – the tree is drawn by generating 3D vectors (with critical parameters of rotationY, rotationZ, length)  for branches and changing them accordingly to their age and their parent branch position.

Written by edzis

January 23rd, 2009 at 11:35 am

Tree generator in 25 lines of ActionScript

with 6 comments

Sample tree by Tree Generator

View Tree Generator

I am writing a bit late, but just wanted to share that I as well had submited my entry for the The 25-Line ActionScript Contest – Tree Generator. For those not yet informed the competition is a revamp of the 2000 Flash MX 6 ActionScript 1 version, made alive by Keith Peters. on time with the release of Flash CS4. It is planned as a regular contest with cool prizes, starting with Adobe CS4 Suite.

Flash has changed a lot during the years and some folks are complaining that AS has become harder, too verbose, and that it takes more code to do the same things compared to AS1. I see this competition as a part of Keith Peters’ initiative to put the Flash Back in Flash.

As I am always amazed by the fields where technology touches the real world, I wanted to build something connected to nature. I know that other have already made really nice trees, but I saw some space for optimisation – sorry, Grant, but trees don’t grow that way. So, I made a growth animation, from a small culm to a full-grown tree only in 25 lines. I did not made it into the top 12, but I still want to share. Take a look at the code and swf and see the November/December Finalists.

Written by edzis

December 11th, 2008 at 1:06 pm

Posted in ActionScript 3, Flash Player 10

Tagged with ,