10,000 Hours. How Long is That?

Malcolm Gladwell writes in his book, “Outliers”, about how long it takes to become really good at anything complex, from building a gigantic software company to becoming a legendary musician. Researchers say it’s 10,000 hours. How long is that? You can find out below..

Get Adobe Flash player

The Undocumented “addFrameScript” Method

There’s a useful function inside the MoveClip class (AS3) that will add script inside a Movieclip on a specific frame without actually having to add it manually to the timeline. This is great if, say you have someone working purely on animation and then someone else working on the interface to hold/play/control the animation. A lot of times this person will need to know when then animation has completed and will therefore need to add script inside the MovieClip animation. The addFrameScript can do this for you without altering the animation and re-exporting, etc.

The function takes two parameters: frame number to place the script (0 based) and the function name to call.

public function addFrameScript (frame:uint, notify:Function):void;

Example:

1
2
3
4
5
6
7
8
 
// animation is the name of the movieclip.. 
animation.addFrameScript (77, onAnimationEnd);      
 
// function called when playhead reaches 76.. 
private function onAnimationEnd ():void { 
	trace ("onAnimationEnd.."); 
}

StopWatch Class

I worked on a couple projects a while back that required a stopwatch (or timer) to keep track of time in a game, so I made this StopWatch class. Found it very helpful so I wanna share it. Besides the basic functions of starting, stopping, and resetting, you can also pass in a TextFormat object to change the formatting of the text, get the time in milliseconds (it’s what I used to store in the database), and parse the milliseconds back into something more readable..

Here’s how to use it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import ca.ryac.StopWatch;        
 
// creates a StopWatch obj and sets the formatting to the txtFormat obj.. 
// last parameter will set embeddedFonts to either true or false (default is false).. 
var sw:StopWatch = new StopWatch (txtFormat, true);        
 
// pretty self-explanatory.. 
sw.start (); 
sw.stop (); 
sw.reset ();        
 
// set or change the formatting and sets embeddedFonts to true.. 
sw.setTextFormat (txtFormat2, true);        
 
// output the time in milliseconds 
trace (sw.time);        
 
StopWatch.parseTime (87292); // returns 01:27:29

Download StopWatch.as

Japanese “Flash Card” Application for Flash Lite Devices

I started learning Japanese not too long ago and to help me with my studies I made a small app to familiarize myself with the Hiragana and Katakana characters. It proved to be very useful while waiting for the bus, taking the train, etc.

Here’s some screen shots:

JP Flash Card App 1 JP Flash Card App 2

You can choose to randomly display the characters for each character set and also show or hide names when the card is first displayed.

I’ve been testing on a Nokia E65 and works well. If you’ve seen this app before, you might have read my comment about the small bug that appeared in Flash Lite 2.x – how the first card was not matching the romanji name. The problem was not enough time was given to completely load the swf before calling some script. I’ve fixed this by giving more time (read as: inserting more frames) for the swf to load completely before calling any script on it. This way, the swf fully loads and is able to jump to the correct frame to match the romanji. So it works in FL 1.1, 2.x, and 3.0 now but I found it a bit strange how this problem only appeared in the newer FL versions (2.x & 3.0).

Please feel free to download it here and give it a try. If you’re studying Japanese I hope it helps!

To find out if your phone has Flash Lite pre-installed, download this pdf file originally available on Bill Perry‘s blog.