January 19th, 2009 — 4:53pm
I’ve just finished the interface for browsing the work day by day. It took much more time then anticipated. This was because as soon as I jumped to another day the program started slowing down to an unacceptable level. I had to figure out why that happened before I could carry on. Finding that out and fixing it took me about five hours!
I finally discovered that a drawing new heart-beat graph slowed down the program because it got bigger with every new day you clicked. This graph is build up from thousands of dots and lines. To make the animation go faster I had to remove those first. But I put them in the wrong place so I couldn’t remove them. I had to rewrite the code for building the graph so I knew where all the lines and dots were and then I could remove them. Now with every day you pick the old graph is removed and a new one is drawn and the speed stays the same.
On the net I found this really nice code for adding listeners to the seven buttons in a dynamic way:
addEventListener(MouseEvent.CLICK, mouse_click);
function mouse_click(event:MouseEvent):void {
var object_name=String(event.target.name);
for (var i:int = 0; i < 7; i++){
if (object_name == day_btn_array[i])
{
get_day_data(event);
}
}
}
So instead of writing all the listeners by hand I now only have three eventlisteners (only one is shown here.) With every click the function finds out what button was clicked. It calls the appropriate function and passes the original click event. In the called function I again retrieve the name of the button from that event using event.target.name again.
Comment » | Uncategorized
January 5th, 2009 — 10:22pm

Columns with time, unused data and beats per minute
I’ve made myself very happy tonight. I decided to write the code that invents the data from the Suunto watch, that was lost yesterday. I wanted the date and times to be right but the beats per minute would just be 10 everywhere. The strangest thing happened when I was programming. I didn’t understand quite what I was doing I just followed the logic without actually using my brain the way I usually do. Step by step I worked through the hour, minute, second and day numbers. They of course have to be incremented with 1, 1, 10 and 1 when they’ve reached a certain value. So when the minutes and seconds are at 59 and 59 a new hour must start and their values must be reset to 09 and 00. I typed it out and it worked the first time! The I only had to add the leading zero for minutes and seconds. And now I’ve got myself 4158 lines of fake data from my Suunto watch
I can use this to prepare the big data file which holds all the data for that day.
Comment » | Uncategorized
December 16th, 2008 — 7:08pm

prototype of the first heart-beat graph
I’ve managed to code my first heart-rate graphic. And it’s CUTE!
By looping through the big data file I can isolate the heart-beats, take the different values to draw lines and put in the dots at the right coordinates. The next step is to draw a big graph in Flash and move it to the right at certain intervals (500 milliseconds for example). Now it still is a drawing that is animated from left to right. It disappears from view after a while, as you can see in the picture.
Comment » | Uncategorized