Archive for March, 2006

Adventures In ActionScript

Friday, March 10th, 2006

Once again, post work nap out of the way, I resumed doing my homework project and learning flash in the process. It seems (like most things) there are many different ways to use flash. On one extreme you can use the timeline along with automagic tweening functionality and very minimal scripts to lash things together, or you can go to the other extreme and use it as a visual programming environment, using object-oriented (well as OO as JS/AS get) externally defined scripts for everything. Being a programmer, I chose the latter.

One of the problem’s I’ve had is resolving fields in the various namespaces, particularly finding one “movieclip” from another. Its odd that everything useful has to be a movieclip or a button, and that you can only apply certain graphic filters to those type of objects. Back to the namespace issue - now that I seem to be able to properly find objects from one another, I encountered the problem that function objects in JS/AS don’t know what object instances they’re associated with like they would in Python. So setting a button’s event handler to call one of the functions in either approach below won’t work: (I wish I new why the editor in Wordpress is effectively double spacing the text below by inserting break tags)


/* approach one :
* fails because doSomething will not be bound to this instance
*/
this.myButton.onRollOver = this.doSomething;
/* approach two:
* fails because this is not pointing to the right thing when it is executed
*/
this.myButton.onRollOver = function() { this.doSomething(); };

At this point I picked my roommate Phil’s brain because he’s always crawling around the obscure guts of languages like this, and found out some of these strange consequences of Javascript not really being OO - that the this pointer sucks and the above facts about the capabilities of function references.

Big thanks to him for pointing out this simple way to fix the problem using a closure:


var a = this;
this.myButton.onRollOver = function() { a.doSomething(); };

And for reminding me that you can do something like MochiKit does in their bind function to make “real” function pointers that know what instance they belong to (in a really stripped down form below)


class BindUtil {
static function bind(obj,func,args) {
return function() {
if (args != 'undefined')
func.apply(obj,args);
else
func.apply(obj);
};
}
}

Because that function makes it possible to pass arguments, one can easily define one handler to use for various buttons inline like this:


this.tempMinusBtn.onPress = BindUtil.bind(this,this.changeTemp,[-1]);
this.tempPlusBtn.onPress = BindUtil.bind(this,this.changeTemp,[1]);

So I’ve got one working dialog for my prototype due on Tuesday, but this is more functional that a lot of the rest will be. Its a screen from a inflight entertainment system we’re prototyping. The screen linked below is the climate control dialog that will fly in from the side to adjust temperature etc. The close button does nothing.

Flash Demo (Requires Flash Player 8 )

Only now do I notice that the control areas aren’t centered. I guess I’ll fix that later.

American Morning on CNN - Wasted Airspace

Tuesday, March 7th, 2006

I was at the gym this morning and noticed a couple of disturbing things on the television. Next to the TV tuned to MTV which seems to play the same 3 videos every morning that I’m on the treadmill, there was one tuned to CNN. I’m starting to wonder if that middle “N” means news anymore.

About 8 this morning, they spent around five minutes talking about McDonalds coffee and doing a blind test test in the studio and with passers by on the street. Is this newsworthy? I guess I now know that people can’t really tell one coffee from another. (If you’re read gladwell, you also know about the effectiveness of blind test tests). I would like to know how much McDonalds was paying for this infomercial segment, and if they aren’t paying, then why CNN is wasting time covering this crap. I’m sure we can find some more topics to talk about, like the anti-free speech crackdown in Kenya. People would probably have been better served by a video of a waving flag.

In the dreaded crawl during this time I notice this (paraphrasing a little because I didn’t have a notebook with me on the treadmill) “Women from 50 countries sign letter to Kofi Annan accusing him of paying lip service to gender equality and doing nothing to promote women’s rights” - Which is completely redundant. That’s what lip service means! You don’t need to add on the “and did nothing” part.

What’s next, defining all the words in the crawl to make sure people understand what’s going on?

My First Flash App

Monday, March 6th, 2006

So I’m learning Macromedia Flash at long last, because I have a prototype due in a week. From the looks of my first little flash app, I have a long way to go.

Mouseover those labeled buttons at the top. I dare you.

Update: Kristi says the red ball doesn’t work for her. It works for me, so I dunno.

Please Sir, May I Pay Some More?

Monday, March 6th, 2006

I did my taxes this past weekend, and had to laugh when I was presented with the opportunity to voluntarily pay a higher tax rate than I would otherwise have to (5.85 % instead of 5.3%):

Extra Tax Prompt

You bet your sweet ass most people say no! I did some quick (read flimsy) research to see just how many people say no and turned up a page taking Kerry to task for not opting to pay the higher tax rate, which also had the only numbers I could turn up. I think it was something like a tenth of a percent of taxpayers, netting the state something like $20k in extra revenue. Yay.

What is wrong with the justice system in Florida?

Thursday, March 2nd, 2006

I was going to title this “What is wrong with Florida” but clearly we could discuss the problems with God’s waiting room all day…

First that old geezer is able to drive around for something like three miles with a freshly dead man hanging through his windshield, and get off without criminal charges by claiming he didn’t notice it until a toll booth operator kindly pointed it out to him. Too bad it wasn’t a gas station attendant, cause then the attendant could have said, “want me to check your oil, remove that corpse from your windshield?”

Moving on… Now I read this kid Lionel Tate who at 12 was already a killer (a 6 year old girl) who got off on a sweet second-degree murder charge is back in court over holding up a pizza delivery man. For three pizzas. At gunpoint.

Florida is letting him plea bargain from probation-violation that would see him in prison for life down to 10-30 years. I think this one has already sufficiently proved himself a menace to society. Lets see:

  • Kills 6 year old at 12 (gets off because of his age, probably teaching him a bad lesson)
  • Caught with 8 inch knife in 2004, clear house arrest and probation violation (gets off with only 5 year probation extension
  • Holds up pizza man for PIZZA at gunpoint (get sweetheart plea bargain)

What does one have to do in Florida before they actually write you off? Who’s going to have the misfortune of crossing Lionel’s path in 10-30 years to prove, again, that Florida should have locked him up the first time?

Update: Thinking about it more, how good can Florida pizza even be? Unless it was someone delivering pizza from New Haven or New York, how can it be worth holding someone up over?