masthead

Holder MovieClips and InteractivePNG Not Working

InteractivePNG is a nifty class that’s been around for a while. Instead of extending MovieClip, you can extend InteractivePNG and it will capture all the mouse events and figure out if the mouse event was actually set off by transparent (or semi-transparent) pixel in a PNG. If so, it will ignore the event and let anything behind the transparent pixel receive the mouse event instead.

One of the things I like to do on the timeline of a view is place a bunch of empty holder MovieClips so I can easily control the layer order of instantiated display objects. Today I was running into a problem where when I placed an InteractivePNG object in a holder MC, InteractivePNG would stop working its magic. The fix is pretty easy in case anyone else needs it - just tell the holder MC to use InteractivePNG as its base class in the properties (formerly linkage) dialog. Magic restored!

Sankey Diagram Generator Code

I’ll add a brief rundown of how it works later, but for now, you can download the code here.

Happy Holidays!

Coke Zero Facial Profiler

Today marks the launch of Facial Profiler, a site for Coke Zero that uses Facebook to find your identical twin. I came on to the project as a Flash developer a few months ago and am very excited to see it finally live!

Go sign up and find your doppleganger. Maybe you guys can meet for coffee sometime.

Colorado Common Ale

Homebrew #4. A California Common (Steam Beer) style. Simple, smooth and delicious. Not that I have any of my old brews left to compare with, but this could be my favorite so far.

Colorado Common (5 gallon, partial mash)

Fermentables:

  • 7lb Light LME
  • 1 lb Crystal Malt

Boil Additions:

  • 2oz Northern Brewer (60 min)
  • 1oz Cascade (10 min)
  • 1oz Cascade (10 min)

Wyeast California Lager (2112). 5 weeks in the primary (I’m not a secondary kinda guy, not yet anyway) and then into 12oz bottles for 2 weeks.

Not as carbonated as I was expecting, though I did sneak this bottle a little early. A minty, earthy aroma - I was surprised that the NB hops come through more than the Cascade. The taste is a different story though, a nice amount of that grapefruity Cascade taste. Not too much. The real “steam beer” taste comes in at the backend, that little bit of malty sweetness.

I’m thinking of going all-grain for the next batch… it’s about time to take it to the next level (if I have enough space here). Maybe a dark and spicy Christmas ale (”All I Want For Christmas is Brew,” with a picture of Mariah Carey on the bottle). See if I can find a used mash tun, or try and make one my self. I also found these instructions for a counterflow chiller, which is something I could definitely use.

Box2DAS3 and AIR/Flex not working

File this under “this is such a stupidly easy fix I can’t believe I wasted so much time on it.” To get Box2DAS3 to work in Flex/AIR, you need to make sure your m_timeStep variable is “1.0/30.0″ and not just “1/30.” Go figure. Didn’t think Flash cared about that stuff. Thanks to this page for giving the answer.

How do I know if a point is within the area of a circle?

UPDATE:

Wow, did I overthink this. No need for all the silly math, just take the distance from the point to the center of the circle, and compare that to the radius. Duh. For humility’s sake, the original post is below.

(Old post)

That is the question I asked myself a few days ago. And here is the answer (my apologies for the poor formatting, I need one of those code display plugins…):

/**
 * Determines whether or not a given point lies
   within a circle
 * @param circleX	The X value of the center
                        of the circle
 * @param circleY	The Y value of the center
                        of the circle
 * @param radius	The radius of the circle
 * @param ptX		The X value of the point
                        to be checked against the
                        circle
 * @param ptY		The Y value of the point
                        to be checked against the
                        circle
 */
public static function isWithinCircle( circleX:Number,
circleY:Number, radius:Number, ptX:Number, ptY:Number
):Boolean
{
	var theta:Number = Math.atan2( circleX - ptX,
circleY - ptY );
	var magnitude:Number = ( ptX - circleX ) /
Math.cos( theta );

	if( Math.abs( magnitude ) > radius )
		return false;
	else
		return true;
}

Here’s how it works: The formula to find the point (x, y) on the circumference of a circle with a center (a, b) is a = x + r cos ? and b = y + r sin ? where r is the radius of the circle and ? is the angle in radians from the center point at which the outer point lies.

Since I already know the location of both points and the radius of the circle, it’s pretty simple to fill in the gaps. I replaced r (for radius) with m (for magnitude) and then solved for m. The one last thing we need is the angle - I did a quick search and found that the angle between two points can be found using atan2 (not that I have any clue what that actually does…). That formula is ? = atan2(dX, dY).

Now when I plug in the points, I can check the value of m against the radius of the circle. If m < r, the point is inside the circle. Otherwise, it is outside. I’m no math expert so I can’t say 100% that this is the correct or the easiest/least processor intensive solution to this problem, but it has worked so far for me.

Graduation Golden Ale

This brew was my third go round at making beer, but the first time I made my own recipe as opposed to buying the ingredient kit. It’s actually a fusion of four or so recipes I found online for Belgian strong golden ales. I picked out qualities I wanted my beer to have and came up with this:

Graduation Golden Ale (Partial Extract, 5 gal boil, og 1068)

Fermentables:

  • 6lb Light LME
  • 3lb Gold LME
  • .7 lb Dingemans Pale
  • .7lb Flaked Wheat
  • .35 lb Dingemans Special B
  • 1.5 lb Clear candi sugar

Boil Additions

  • 2oz Sterling (60)
  • 1.5 tsp Irish Moss (10)
  • .3oz Cardamom (5)
  • .3oz Ground Coriander (5)
  • 1oz Saaz (1)

Yeast: Wyeast Belgian Strong Ale

Tasting notes: Pours a little darker than I was hoping for, more of an amber color, with a big, persistent off-white head. The cardamom comes through big in the aroma, definitely overpowering the saaz. I would say that’s a matter of less cardamom, not more hops. The taste is sweet, both malty and sugary. The spices are there too. There’s a nice bitterness on the backend. Plenty of alcohol in here as well… my amateur calculations put it at 7.5%.

If I were to do this again, I might lose the Special B. It made the beer too dark and I’m assuming it added complexity to a beer that was already complex enough.

Today I brewed a california common, which I’ll write up in a month or so.

Installing Flash Tracer on a Mac

Flash Tracer is a must-have Firefox Plugin that, as the name suggests, shows you the trace outputs from a swf right in your browser. I’ve had to install it on a few different machines and each time I always forget how, so I wrote out some step by step instructions that I want to share with the internet.

  1. Make sure you have the Flash Debug Player: http://www.adobe.com/support/flashplayer/downloads.html. Click on “Download the Macintosh Flash Player 10 Plugin content debugger (Intel-based Macs).”
  2. Install FlashTracer: http://www.sephiroth.it/examples/firefox/extensions/flashtracer.xpi
  3. Create an mm.cfg file.
    1. Open Terminal
    2. Locate your root folder (type “cd ..” once or twice. To make sure, type “ls -l” and if you see folders like “Library” and “Users” in the right column, you’re good)
    3. Type “cd Library/Application\ Support/Macromedia”
    4. Type “pico”
    5. Type “ErrorReportingEnable=1″ hit enter, and type “TraceOutputFileEnable=1″ (no quotes)
    6. Press Ctrl + O (even though you’re on a Mac, it’s Ctrl, not Command)
    7. Type “mm.cfg” and press enter
    8. You can confirm that the file has been created by navigating to that folder in Finder and opening mm.cfg with a text editor.
  4. Restart Firefox
  5. In Firefox, click Tools > FlashTracer. In the FlashTracer column, click on the orange wrench icon at the bottom right.
  6. Click on “browse” next to “Select Output File” and navigate to “/Users/{username}/Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt.” There should be a flashlog.txt file there by now - if there isn’t, go to a website that has Flash content on it (thefwa.com) and it should be created.
  7. That should do it. Restart Firefox again to be sure.

In addition to helping debug your projects, using Flash Tracer on other people’s sites is a nice form of entertainment.

“The Dock,” A real-life Arduino-powered OSX dock

For my final project in Physical Computing, I’m making a real-life Mac OSX dock, with little Sculpey icons that you can use to open and close programs.

First some pictures: the outside, the inside and the icons.

It works by measuring the values of resistors that I glued on to my icons. Each pair of brass washers coming out of the box acts as a switch that can only be turned on by putting an Icon on top of it. Any icon can be placed on any spot in the dock, which completes the circuit. A wire leads to the analog inputs on the Arduino board, which reads the value and then sends out a character over the USB serial port. Each icon has a unique character for it being placed on the dock and for it being removed from the dock.

Reading those serial calls and having them control the applications was harder than I expected. My first plan was to use ASProxy, a program which runs different AppleScripts based on a character received over serial. Sounds perfect, but it didn’t work with how I had coded my handling of the circuit. It seems that to get good results from ASProxy, you have to write the character to the serial port often over many calls to Arduino’s loop() function. In my program, I only write to the serial port once, and I have a hefty delay between loops so that brief connection outages won’t produce odd results (for example, if someone knocks the icon off but then quickly places it back on. Magnets are going to be my next solution to this).

The next solution was to try and have Processing handle calling AppleScript functions. That led me to this Processing hack which doesn’t seem to work anymore. Processing didn’t like having to import that library - but there is a solution to this! Gotta love the Processing forums. You can call AppleScript by using shell scripts, as described here.

I still have a few problems to fix before this works perfectly. It seems that Processing is receiving serial calls even after I have placed and removed an icon. For example, if I place my iChat icon on and take it off, it works fine, but then will continue to open and close iChat. So I need to look into where those calls are coming from (using the extremely useful ZTerm, which has made many things in this process much easier). Also magnets would be a nice touch, so I will figure out a way to have them as well.