Archive for the ‘Basics’ Category


February 23, 2012 Leave a comment

v_mag = 5
v_ang = 0

c.onPress = function(){
c.onRelease = function(){

b.onEnterFrame = function(){
dist = Pythagoras(b._x, b._y,c._x, c._y)
if(dist > 100){
v_ang = getAngle(b._x, b._y,c._x,c._y)
vx = v_mag*Math.cos(v_ang)
vy = v_mag*Math.sin(v_ang)

b._x += vx;
b._y += vy;

function getAngle(x1, y1,x2, y2):Number{
distX = x2-x1
distY = y2-y1
ang = Math.atan2(distY, distX)
return ang

/*b.onPress = function(){
b.onRelease = function(){
b.onEnterFrame = function(){
//min = (b._width +c._width)*0.5
//dist = Pythagoras(b._x, b._y,c._x, c._y)

c._x += 1
function Pythagoras(x1, y1,x2, y2):Number{
distX = x2-x1
distY = y2-y1
z = Math.sqrt(distX*distX + distY*distY)

return z

Categories: Basics

Let’s Get Started

February 20, 2012 Leave a comment

I’ve been delivering a module that introduces Mathematical manipulations to simulate physics environment in my workplace. It’s my interest to get students across the hurdle of programming interface in the shortest time and really dip into the Math. After trying several rounds of AS 2.0 and AS 3.0 with batches of students, I find students benefitted most when I used As 2.0.

While Actionscript 3.0 had been rocking for the past 5-6 years, whenever it comes to teaching and learning for fresh students (absolute beginner in programming), I still find Actionscript 2.0 superior. Here are a few observations:

  1. Less-overwhelmed. AS 2.0 has a smaller set of tools compared to AS 3.0. Students reach the boundary of what’s possible through API sooner and will look elsewhere like Math to improve + build upon the basic scaffolding provided through API calls.
  2. Syntatically simpler. Needless to say, they are able to write their own AS 2.0 easier.
  3. Structurally simpler. Although AS 2.0 do make use of event model, but structure required to write it is short. No separate function to do the event handling, you can write all in one line.
  4. Loosely typed. Variable declaration is loose. No need to get know the exact datatype of variables. Students will not know the whole extend of things they can create initially, so this help is valuable for jump start.

Now I’m not undermining the importance of knowing AS 3.0. My point is rather to start students off easily using AS 2.0, then only at level 2 (or upon their own effort) usher in migration to AS 3.0.

There’s advantage in knowing both these programming structures. AS 3.0 is mature in the way the language is structured and libraries are organised. It’s comparable to the way Java and C# programs are being written. On the other hand, AS 2.0 is a little similar to Javascript, which is used to develop HTML 5.0 games. So students get a taste of both worlds. As the need to program for different platform comes, they can quickly adapt because they are exposed already.

Categories: Basics