Archive for February, 2010

Patching NetStreamClient

(February 14th, 2010)

I couple of days ago I noticed that my conceptual NetStreamClient was failing when connecting it towards a NetStream, the debugger threw errors regarding missing a Proxy implementation of getProperty.

The problem was when building the class I took for granted that NetStream referenced against the client object and invoked the callback function from the object when a callback took place. But the fact is that when you assign a client object to netstream it saves a reference to the callback function, not the client object itself. So it was clear why my class didnt work.

So I patched it up with the proxy implementation getProperty (it looks a bit hackish but it does the trick).

flash_proxy override function getProperty(name:*) : *
{
        var qName:QName = name as QName;
       
        return function ( args ) : void
        {
                flash_proxy::callProperty( qName, args[0] );
        }
}

I also noticed that in my usage example I used an object instead of the NetStreamClientEvent. So this is how you “really” use it.

// create a instance
client = new NetStreamClient();
// assign the client
netStream.client = client;
// then just add listeners to the client
client.addEventListener( NetStreamClientEvent.CUE_POINT, client_cuePointHandler );

// an example of the handler function
function client_cuePointHandler ( event:NetStreamClientEvent ) : void
{
        // the info object holds the original data
        var info:Object;
                       
        info = event.arguments[0];
                       
        trace( [info.name, info.time, info.cuetype] );
}

Updated classes here: Download it here here, or view the NetStreamClient class here.

Note to self: Connecting MySQL with Django using Mamp in OSX

(February 14th, 2010)

Having trouble connecting your MAMP mysql database wth django?

Add the path DATABASE_HOST and connect it towards

{path to your MAMP directory}/tmp/mysql/mysql.sock

So my connection is for instance

DATABASE_HOST = ‘/Applications/MAMP/tmp/mysql/mysql.sock’

And the full mysql settings for for django

DATABASE_ENGINE = ‘mysql’ # ‘postgresql_psycopg2′, ‘postgresql’, ‘mysql’, ’sqlite3′ or ‘oracle’.
DATABASE_NAME = ‘mydb’ # Or path to database file if using sqlite3.
DATABASE_USER = ‘root’ # Not used with sqlite3.
DATABASE_PASSWORD = ‘root’ # Not used with sqlite3.
DATABASE_HOST = ‘localhost’ # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ‘8888′ # Set to empty string for default. Not used with sqlite3.
DATABASE_HOST = ‘/Applications/MAMP/tmp/mysql/mysql.sock’

Its straightforward, but good to know, since adding the mysql.sock file in a folder named tmp seems a bit odd.