Home arrow Latest articles
Latest articles
Collision detection & bouncing part 3: bouncing balls Print E-mail
Sunday, 10 September 2006
This is the third article on collision detection and bouncing in Flash. This article will explain how collision works between a light object and a much heavier object, such as a ball and a wall. In this case the collision response is quite simple because the heavy object is not affected by the collision.
This article builds on the algortihms explained in the first and second article.
Read more...
Collision detection & bouncing part 2: actionscript examples of collision detection Print E-mail
Tuesday, 06 June 2006
At a jiu-jitsu seminar I asked a Japanese grandmaster which was the preferred way  to do a certain wrist lock. He answered: "Life has many ways, choose one".
The same wisdom applies to collision detection. There are many ways to implement the intersection-of-line-segments-formula I explained in the first article. In this article we'll explore some algorithms in Flash to detect collisions of a moving circle or polygon enclosed by another polygon.
Read more...
Collision detection & bouncing part 1: intersection of line segments Print E-mail
Sunday, 23 April 2006

This is the first article in a series about collision detection and bouncing in Flash. Before we get to the real stuff, we need some preliminary knowledge: we need to know how to intersect line segments.
In this article I'll show two ways to calculate the intersection of line segments. First we'll use the Slope-Intercept form of the lines to find their intersection. The second method uses a parametric equation, which will prove to be more elegant and require less time to compute.
Sample code is provided in Flash.

Read more...
The Unicode Workflow Print E-mail
Tuesday, 11 April 2006
ImageI was tired of finding myself utf8_encode()'ing and utf8-decode()'ing all over the place when dealing with multi-lingual Flash and HTML sites. My solution is the Unicode Workflow, a big word for a couple of simple rules which will save you a lot of headaches.
Read more...
parseFloat("512.56")*100 doesn't equal 51256 Print E-mail
Wednesday, 22 March 2006

Math.floor( parseFloat("512.56") * 100 ) results in 51255, while I (and my client) was expecting 51256.
This is very annoying when your coding an online tax calculation program in Flash. So I tried to pin down the problem.

What happens in the program. The front-end is written in Flash, the back-end is a webservice written in C++. To avoid roundoff errors, the webservice works with integers only. All amounts are multiplied by 100, to be able to work with cents and still use integers. This is common practice in financial software.   Since € 110.125 is an invalid amount, (1 cent is the lowest valid amount), we decided to chop off the digits entered by the user after the 2nd digit after the decimal point.
So the user enters an amount in a TextField. This is a string. I convert it to a Float with the parseFloat() function. Then I multiply the Float by 100 and round off to lowest Integer. "512.5677" would result in 51256, thus ignoring digits behind the second digit after the decimal point. "512.56" Should result in 51256 too, but it doens't.

Read more...