Category Archives: Professional

New code, new dev environments

As part of my effort to try new code, I’ve been mucking around in Python, Node.js, and Ruby on Rails.

Setting up a coding environment is a daunting challenge. I have a brand new mac book air with os 10.8. And I’m doing things in terminal I’ve never done. But I’ve been able to set up the necessary, code, packages, frameworks… what have you all without running sudo.  I don’t know much unix but I know know, sudo is like doing internal engine work on your car.

I’ve been using Homebrew. I don’t know how i found it but it hasn’t let me down.

And Now, For Something Completely Different…

Rafting Guide School
Rafting Guide School

New city, new coast, and now… a new professional pursuit.  I left my awesome job at Yahoo working and ran off to white water rafting guide school in May.  After two weeks of intense training, I returned to Portland, and I’ve begun to pick up work guiding trips on the Clackamas River.

While not on the river, I’m playing around with new coding environments rediscovering why I got into software development in the first place.

I’m grateful to my team at Yahoo.  I had a great run there.

MySpace Face Recognition App

I was called into complete a Face Recognition Flash app for MySpace last week.  It was a promo for the Black Eye Peas.

After you give permission for Flash to turn on your camera, it locks in on your face (center your face for this) and then song begins. Cute 8bit art gets blasted on to your face (sunglasses, old game icons, etc).  You can move your face around and the art will follow you.  And then you can snap stills of the silliness with a button. When the song ends you can select screen grabs to upload to your MySpace account.

We did encounter one problem with Flash accessing the camera on some macs.  Apparently there is a bug with Mac OS 10.6.5 and the camera.  However there is a work around.

Cloning a MouseEvent

I’ve seen the question of how to dispatch a MouseEvent through code, but i’ve never seen it answered. I figured it out so i’ll share it with your here.

Let’s say you have a BallSprite class and a RectSprite class (BallSprite being a graphic of a ball…..etc). And i want a MouseEvent.Click on an instance of BallSprite to trigger a MouseEvent.Click on an instance of RectSprite

Give the instance of BallSprite access to the instance of RectSprite. Note how i dispatch a clone of the click on the BallSprite instance. Now any MouseEvent.Click listeners on RectSprite instance will be triggered.

[cc lang=”actionscript”]
package myClasses
{
import flash.display.Sprite;
import flash.display.DisplayObject;
import flash.events.MouseEvent;
public class Ball extends Sprite
{

private var _rect:Rect;
public function Ball(dispObj:DisplayObject)
{
_rect = dispObj:DisplayObject;
this.addEventListener(MouseEvent.CLICK,clickHandler);
// add a graphic to our Ball instance
this.graphics.beginFill(0x00ff);
this.graphics.drawCircle(50,50,50);
this.graphics.endFill();
}

private function clickHandler(e:MouseEvent):void {
trace(‘ball click, now rect dispatches click’);
_rect.dispatchEvent(e.clone());
}
}
}

[/cc]

Random Tile class

Here’s an Actionscript 3 class I wrote the places tiles on a grid – either randomly or in order, with no overlap, and allows for a tile free zone.

You can see it in action here.
[cc lang=”actionscript3″ nowrap=”true” width=”550″]
/**
* coding by mike Connor – flashDeveloper@rocketnumber9.org
*
* randomly places tiles on a grid so that o not overlap and do not fall in dead tile zone
*/
package utils
{
import flash.display.DisplayObject;

public class RandomTile
{
private var numOfRows:uint;
private var numOfCols:uint;
private var rowArray:Array;
private var tileArray:Array;
private var unplacedArray:Array = new Array();
private var _gridW:uint;
private var _gridH:uint;
private var _maginTop:uint;
private var _marginLeft:uint;
private var _deadTiles:Array = new Array();
private var _randomLayout:Boolean;

public function RandomTile(r:uint, col:uint, ta:Array, gridW:uint = 76, gridH:uint = 76,
maginTop:uint = 2, marginLeft:uint=1, randomLayout:Boolean= true, deadTile:Array = null)
{
rowArray = new Array();
_randomLayout = randomLayout;

numOfRows = r;
numOfCols = col;
tileArray = ta;
_gridW = gridW;
_gridH = gridH;
_maginTop =maginTop;
_marginLeft = marginLeft;
if (deadTile !=null) _deadTiles = deadTile;
if (numOfRows * numOfCols < (tileArray.length - _deadTiles.length)) { throw new Error("Error - too many tiles, not enough spaces"); } else { init(); } } private function init():void { for (var i:uint=0; i= numOfCols){
colCount = 0;
rowCount++;
}

}
Debug.trace_msg(“DONE placeTiles in order”, Debug.DEBUG_VERBOSE);
}

private function placeTilesRandomly(arr:Array):void {
for (var i:uint = 0; i