Why Doesn’t My Phone Show Missed Calls?

Posted in Misc on June 8th, 2010 by helloworlder – 1 Comment

This has got to be the most annoying mobile phone problem I’ve encountered. It doesn’t show the numbers of missed calls. It used to. Now it doesn’t. What the hell?

But I’ve heard worse. I have a friend with a phone that has the buggiest software like alarms not going off at the set time (yes he was late to something when the alarm failed to go off in the morning), and contacts being randomly deleted without input from the user. Apparently that phone’s poor software has been over-compensated with the strongest physical armor to protect it from bangs and drops.

I dislike Apple’s hypocrisy when it comes to open standards and propriety software and hardware, especially it’s fiasco with Adobe recently regarding the Flash CS5 packager for iPhone, but maybe it’s time to get an iPhone … now just need some money :/

The Dangers of the Flash TileList Component

Posted in Actionscript 3.0 on May 5th, 2010 by helloworlder – Be the first to comment

I have decided that the TileList component in Flash Professional is a potential time-saver, but also a potential nightmare and a total mess if you use it for more complex applications. Basically a TileList if you don’t know is a component that displays a list of items typically in a grid configuration and typically as images.

I’m going to assume that most people provide data to a TileList instance programatically at runtime using AS3, instead of manually inputting data from the GUI (if that’s even possible).

The first thing you should know about using a TileList is the way you load add items to the data provider. Garbage collection is one of those things that cause really frustrating bugs that keep you up at night. This StackOverflow page is a MUST read if you want to ensure some measure of sanity when working with the TileList component.  The second answer (related to GC) is the one that helped me, although you should see the first one as well. To understand the next part, you need to understand the process of how items are loaded into a TileList - see the StackOverflow page, answer number 1. Notice how once a load is a complete, it triggers the next load, and so on, until all loads are complete.

The second thing that that caused grief was when I wanted to add a feature to remove everything in the TileList and reload it with new data - This would happen when the user selects a new category of items to display from a combo box dropdown. This sounds simple but problems creep in as you consider the issue of asynchronous events. In an ideal situation (which by the way never happens in reality),  a user would select a category from the combo box drop down and wait for all the images belonging in that category to load into the TileList. (This isn’t instantaneous- images need to be loaded one at a time and this takes time). The question is - what if the user selects another category in our combo box dropdown before the images of the current category are all loaded? Well, this will cause the images of the new category to load into the TileList, as well as the ones in the previously selected category.

That is a problem because you cannot easily terminate images from loading once they have started.  Another problem is evident when you start switching between categories really quickly. Now there are many images to load in a short period of time. A “backlog” of event listeners attached to your loaders will start to form, and you don’t know when they will be handled by an event handler, but they will be - at some indeterminate time. So you can have images from one categories appearing when you fast switch to another category. It’s a mess.

I can’t give a solution in code here here partly because my solution is still very messy and very specific to my application. Basically — I used variables to check if a load was in progress and whether a load should be terminated, and also dispatched a custom event called “loadTerminated”, which was caught and handled by a function from which a new load was initiated. I also had to develop a filtering system to make sure that images did not end up in the wrong categories, and also having repeated images from the same category appearing in the TileList. To do this I created an incrementing number which would increment every time a new category was selected, then I would assign that same number to all the images that belonged in that category (I have the image metadata in advance stored in objects of type Object). If the loaded image did not have the same number as the incrementing number, then it would be discarded.

Intermittent Bugs Related To Garbage Collection

Posted in Actionscript 3.0 on March 15th, 2010 by helloworlder – Be the first to comment

I’ve been working with Actionscript 3.0 for some months now, and I’ve tripped over more than once when it came to garbage collection and memory management in general. Be very careful about letting local variables go out of scope, because the garbage collector may (or may not!) come to remove that variable before it finishes doing its job. This also results in one of the most frustration types of bugs - the intermittent bug.

For example, I used AS3’s TransitionManager class which allows you to create animations through code easily. I created an instance of the TransitionManager within an onclick handler, and used it to do slide a MovieClip onto the screen. However, sometimes the animation would stop before reaching the end. It might have stopped halfway, a quarter of way … every time it was different, but most of the time the slide in would complete. The problem was that the instance of TransitionManager was going out of scope as it was created in a method (in this case an onclick handler to be exact). Much of the time the garbage collector did not destroy the instance of the TransitionManager before it finished doing its animation, but sometimes it did, thus causing the animation to stop.

What I did was to make the instance of TransitionManager into a class variable. There might be other ways to do this though … Anyway the next time you see an intermittent bug in your program, it can be due to any reason - but remember this :-)

The Ongoing Role Of Flash On The Internet

Posted in Actionscript 3.0 on March 1st, 2010 by helloworlder – Be the first to comment

Flash already has an important role on the Internet when it comes to general interactive applications,  games and video.

Then there’s HTML5, which is supposedly going to replace many instances where Flash would otherwise be used. YouTube has been experimenting with using HTML5 instead of Flash. However, there is not yet any reason to believe that HTML5 and AJAX technologies will become a significant threat to Flash. The fact that HTML5 is an open standard doesn’t automatically put a halo on its head and a path to RIA domination, even though that may happen in the future.

Then there’s the ongoing Flash accessibility issue. Sure, Adobe has its fair share of problems and yes they still have, but they are concerned about accessibility and have been making improvements over time. For example, can screen readers read SWFs? Yes, they can. In fact, to provide accessibility developers can even provided built in readers and voice overs recorded by real people. Can users tab through components? Yes. The problem is becoming less of an issue of Flash itself than an issue of inaccessible design by developers. Remember, you can write inaccessible AJAX too.

The more relevant question regarding accessibility is now becoming  “Can Adobe provide developers with easier ways to implement accessibility?” instead of “Is Flash accessible?” Flash today isn’t the same as Flash 10 years ago, and I’ll bet you Flash in 10 years won’t be the same as Flash today.

Finally, while the Flash Platform is not open source, the SWF file format specification is open and free of charge to anyone. Yes, that includes you Apple!

I might be wrong, but I think Flash is not only here to stay, but we’ll see more diverse applications of it in the future. But I’m not betting on this one :-) The thing is, don’t dismiss the technology.

http://www.adobe.com/accessibility/

Why Do Package Names Start With com. In Actionscript 3?

Posted in Actionscript 3.0 on February 16th, 2010 by helloworlder – 1 Comment

Question:

Why do package names start with com. in Actionscript 3?

By the way, I’m guessing you already know that package names map to folder names. E.g. an as3 source file in the package com.example must be under the folder example, which in turn must be under the folder com..

Answer:

Package names do not have to begin with com. However, it is the convention to do so. E.g. com.thebestcompany.thebestproduct

What is the significance of com? Well, the package name is simply a domain name reversed. E.g com.helloworlder.utils

The domain name technically does not have to exist but you should own it. Obviously never use someone else’s domain name!! That’s just rude. It is standard practice to use a domain name because it helps to guarantee that your package names don’t collide with the names of someone else’s package on the other side of the world.

If I release some AS3 code that creates popup windows, I may place the code in a package called com.helloworlder.utils.popupwindow and not simply popupwindow

Likewise, if I download some third party code to use in my own project I’d expect their code to be packaged properly. E.g. com.goodbyeworld.utils.modalwindow. Then, I can just place their goodbyeworld folder under by own com folder.

Just as importantly, putting your as3 files into packages helps you think about how to organize the files. Often people place all files (their own and 3rd party code) under one folder! The advice is - don’t.


Unit Testing AS3 Code on the Flash CS4 Platform

Posted in Actionscript 3.0 on February 15th, 2010 by helloworlder – Be the first to comment

I’m developing a project on the Flash CS4 platform and finally started unit testing my AS3 code.  Not doing unit tests seems lazy and negligent. The only reliable unit testing framework I’ve found so far is asunit, which is open source. The Flash CS4 platform has been traditionally targeted at designers and not programmers so unit testing was somewhat neglected in the past.

Installation is very simple. Just unzip the archive and place the as3 folder anywhere on your system. Then in Flash CS4 go to Edit->Preferences and click on the button “Actionscript 3.0 Settings” at the bottom of the popup.  You need to add both of the following paths under “Source path”:

as3/src/

as3/test/

IMPORTANT: Don’t just add as3/ otherwise the framework files won’t be found.

That’s all for the installation. For usage, the asunit website has enough information to get you started.

Javascript Tutorial - Digg Style Selectors

Posted in javascript, tutorials on December 5th, 2009 by helloworlder – 5 Comments

If you’ve posted stories to Digg before then you’re familiar with the “Choose a Topic” form. This form allows you to select which category your Digg submission belong and then lets you submit the form, all without using radio buttons. This tutorial tells you how to achieve the same effect. But I warn you that this Javascript code will not be degradable. If it’s any consolation, if you disable JS on the Digg website their form will also not work. I’m not trying to encourage obtrusive Javascript, but this is a tutorial and not production code. If you want you can build on the code to make it non-obstrusive.

digg_selection

Digg’s Choose a Topic form

digg_style_select

Our version of it (it’s better isn’t it?)

First, create a new HTML file with the following code, and call it anything you like:

<html>
<body>
<head>
<title> Digg Style Selectors </title>
<script language="JavaScript" type="text/javascript" src="digg_selector.js"></script>
<link rel="stylesheet" href="stylesheet.css" type="text/css" />
</head>

<h1> Digg Style Selectors </h1>

<hr />

<form action="CHANGE_THIS.php" method="POST">

<div id="container">

<a href="javascript://" class="digg_style_link" id="1"> Link 1 </a>
<a href="javascript://" class="digg_style_link" id="2"> Link 2 </a>
<a href="javascript://" class="digg_style_link" id="3"> Link 3 </a>
<a href="javascript://" class="digg_style_link" id="4"> Link 4 </a>

</div>

<input type="hidden" name="hidden_data" id="hidden_data" value="nothing" />
<input type="submit" value="Submit" />

</form>

</body>
</html>

To note here is the inclusion of the “digg_selector.js” file which we will look at next. Also important is the hidden field with the id of “hidden_data”. Since what we’re doing is replacing the functionality of radio buttons with nicely styled links, we need another way to get the information submitted and we do that with the hidden field. That’s where the Javascript file comes in:

window.onload=function() {
    var container = document.getElementById('container');
    var containerAnchors = container.getElementsByTagName('a'); // get anchors
    for(var j=0;j<containerAnchors.length;j++)
    {
        containerAnchors[j].onclick = handleClick;
    }
};

function handleClick()
{
    document.getElementById('hidden_data').value = this.id;

    var container = document.getElementById('container');
    var containerAnchors = container.getElementsByTagName('a');

    // unhighlight all the links
    for(var j=0;j++;containerAnchors.length;j++)
    {
        containerAnchors[j].style.backgroundColor = "#eceff6";
        containerAnchors[j].style.color = "#3b5998";
    }

    // highlight the link that was just clicked
    this.style.backgroundColor = "#3b5998";
    this.style.color = "#ffffff";
}

This is simple - there are just 2 functions. Looking at the first one:

window.onload=function() {
    var container = document.getElementById('container');
    var containerAnchors = container.getElementsByTagName('a'); // get anchors
    for(var j=0;j&lt;containerAnchors.length;j++)
    {
        containerAnchors[j].onclick = handleClick;
    }
};

When the page is loaded, we get all the anchors in the container div (these anchors are the digg style selectors/buttons or whatever you want to call them). Then, inside the for loop we attach an event handler to each anchor, which executes when the anchor is clicked. The event handler is a function called handleClick(), which we look at now:

function handleClick()
{
    document.getElementById('hidden_data').value = this.id;

    var container = document.getElementById('container');
    var containerAnchors = container.getElementsByTagName('a');

    // unhighlight all the links
    for(var j=0;j<containerAnchors.length;j++)
    {
        containerAnchors[j].style.backgroundColor = "#eceff6";
        containerAnchors[j].style.color = "#3b5998";
    }

    // highlight the link that was just clicked
    this.style.backgroundColor = "#3b5998";
    this.style.color = "#ffffff";
}

The line document.getElementById(’hidden_data’).value = this.id; gets a hold of the hidden field we talked about earlier, and dynamically sets its value to this.id . So what is this.id? Well, this refers to the anchor that gets clicked on. So this.id gets the id of the anchor. The hidden field is set, and when the form is submitted we can get the value of the hidden field in the $_POST['hidden_data'], assuming you’re using PHP.

Finally, here’s the CSS stylesheet, which needs to explanation:

body
{
font-family: "lucida grande", tahoma, verdana, arial, sans-serif;
font-size: 15px;
}

a:link {color: #3b5998}
a:visited {color: #3b5998}
a:hover {color: #3b5998}
a:active {color: #3b5998}

h1 {
font-family: Georgia, serif;
font-style: italic;
font-size: 20px;
font-weight: bold;
}

hr {
color: #A8A8A8;
height: 1px;
}

#container {
margin:0;
margin-top: 20px;
margin-bottom: 20px;
}

.digg_style_link {
color: #3b5998;
padding: 3px;
margin: 3px;
margin-bottom: 20px;
background-color: #eceff6;
text-decoration: none;
border: 1px solid #d4dae8;
}

That’s pretty much all there is to it.

Web App #2 - Another Facebook App

Posted in php on December 3rd, 2009 by helloworlder – Be the first to comment

So, this is my 2nd Facebook book app and it’s an FBML app this time, not an iframe. You can find it at http://apps.facebook.com/makedebate . It’s called “Make Debate” and you can share your (passionate?) opinion on topics with friends and other Facebook users.

It’s more fun (and easier) to build a site using FBML rather than using an IFRAME app. You can just use FBML tags rather than lots of PHP API calls.

Web App #1 - A Facebook App

Posted in Facebook, php on November 23rd, 2009 by helloworlder – Be the first to comment

This was my first Facebook app and can be found at http://apps.facebook.com/try-to-pronounce-it

What the app does it let you upload pronunciations of phrases in a foreign language and share it with others. I think the fatal flaw of this app would have to be that users have to upload WAV files instead of any format they want. This opens up a lot of issues with usability. For example, the windows sound recorder does not by default save the recorded sounds as WAVs, and since WAVs are uncompressed they are large. In addition, streaming WAVs in the browser is awkward - whereas with MP3 files I could just use a SWF player to stream the files in a nice way.

In fact, at once point I had successfully implemented the FFmpeg library to allow the user to upload almost any file type they want, and the app would automatically convert that file to MP3. Also, since the files were all in MP3 format, I could stream it in a nice SWF player. Unfortunately I discovered that the MP3 (and other codecs) were patented and the usage of them wasn’t actually legal. Pesky software patents …

A Web App a Week Challenge

Posted in php on November 4th, 2009 by helloworlder – Be the first to comment

Now I’m back from Europe and starting to look for a job. While the job seeking is going on, I’m going to try to give myself a challenge that is to try and create one web app each week until I get a job!

The first web app should be up in a few days (err, hopefully).

EDIT: Well this is taking more than a week, but I should have my first Facebook App up within a day or two. It’s written in PHP. At first I wanted to use the Codeigniter framework but it was virtually impossible getting it to gel with Facebook so I went with straight PHP, unfortunately.


Easy AdSense by Unreal