Posts Tagged ‘Flash’

I couldnt believe the Math.round() function in AS3 is so crippled. All it returns is the nearest integer value and ofcourse there is no way you can specify what is the precision of rounding. To make it worse it always rounds 1.5 to 1. Hmmm..

But the solution to this problem is pretty simple.  For example if u want a 2 decimal place rounding all we have to do is multply with 100,then round it and then divide it by 100. Confusing..well here is the code:

public static function roundDecimal(num:Number, precision:int):Number{

var decimal:Number = Math.pow(10, precision);

return Math.round(decimal* num) / decimal;

}

Well that was pretty simple right. Now go coding..all the best.

Unlike C and java where u can declare an m x n array simply by writing arr[m][n], its a bit difficult in actionscrpit3.
It was like u have to make an array of arrays:

new Array(new Array(),new Array(),…)

But a little bit effort can find a way out of this mess. You may make use of the following snippet:

function arrayTest(){

var m:int = 2;
var n:int = 2;
var mainArr:Array = new Array(m);
var i:int;
var j:int;
for (i = 0; i < m; i++) {

mainArr[i] = new Array(n);
for (j = 0; j < n; j++) {

mainArr[i][j] = “[” + i + “][” + j + “]”;

}

}
trace(mainArr);

}

It is a bit of a mess but it will work for sure..

Sometimes you need to pass more than one arguements other than the “event” object. In that case you can use the following code:

//–Listener Function–//

private function listenerFunction(e:MouseEvent,passedVariable:Object): void {
        trace(passedVariable.name);
 }

---------------------------------------------------------------------

//--Caller--//
private function callerFunction(): void {
      var callerObject:Object = {name:"I have a name for sure..."};

            someObject.addEventListener(MouseEvent.CLICK,function (e:MouseEvent) : void {
                  listenerFunction(e,callerObject);
            });
}

Hope that was useful.

I have always wondered how wierd are these Japanese names. I have even thought thesr Japs are crazy. Although I didnt get a reason to think the other way, I just found a cool Flash Toy that can convert your name to the corresponding Japanese name.

My Japanese name is Arikazukashiki ari medorinkashi.
And yours?

May be thats just a toy, as the name suggests, but still it was good to see those names coming up..Now I am gonna ask my mom to call me Arikazukashiki ari medorinkashi…so that the next time she wants someone to help her in the kitchen,she has a good reason not to call me..

Starting Flash

Posted: May 13, 2009 in Technical
Tags: ,

Yeah Flash..CS4…seems a bit out of place for my resume,but still working on flash for sometime..atleast for the next 6  months. Afterall its not so bad to work with..I am doing some physics simuations. Need a lot of math to make it work and then need to put it into action script (AS3). That is something good for me…anyway lemme give it a try..