Make a Little House

RSS
Nov 1

Cool little open source 3D framework for Flash Stage3D

The team working on a new Flash-based 3D game released their 3D framework as open source. Some nice sample apps on the site. Check it out.

Nov 1

mark[sweep]: Lean Startup: The Missing Chapter

marksweep:

I recently finished The Lean Startup by Eric Ries. This is a seminal business book. The Lean Startup takes its name from the lean manufacturing techniques made famous by Toyota Motor Corporation. It applies some of the principles and techniques learned from lean manufacturing and…

paulstamp:

Wow! Unity3D is to export to the new MoleHill API for Flash. This means you will be able to use a Unity3D API in Flash or have Unity convert your C#, Javascript into Actionscript within Unity or better still code AS3 directly in the Unity tool. This is very exciting, not to mention opening up the awesome Unity3D set of tools to the huge 3D tool starved Flash community, I’m stunned by this announcement.
read the article on the Unity3D blog or the article on the adobe blog

paulstamp:

Wow! Unity3D is to export to the new MoleHill API for Flash. This means you will be able to use a Unity3D API in Flash or have Unity convert your C#, Javascript into Actionscript within Unity or better still code AS3 directly in the Unity tool. This is very exciting, not to mention opening up the awesome Unity3D set of tools to the huge 3D tool starved Flash community, I’m stunned by this announcement.

read the article on the Unity3D blog or the article on the adobe blog

AS3( Dev ):Blog{ //Paul Stamp }: Greensock

paulstamp:

I first came across Greensock a few years ago when looking for an AS3 tweening engine. At the time the native flash tweening framework didn’t cut the mustard and still doesn’t. I tried Tweener and GTween along the way and liked both, but was won over by Greensocks TweenMax &…

Dec 3

Super simple Metrics in ActionScript 3

Flex Builder’s Flash Builder’s profiler is great for finding bottlenecks in your application. But when optimizating specific methods and calls, you may find the profiler is overkill…and often tedious to get rolling.

I created a simple Metrics class that let’s me output time in milli’s between designated start and end points. Nothing mind-blowingly slick or clever here. Just useful. It even works on recursive calls. I usually override the log method use Flex’s debug targets, but trace is fine.

Here’s how you use it:

var metrics:Metrics = Metrics.getInstance();
var tk:String = metrics.startTimeTrace( "traceExample" );
				
// Put some cool and expensive code here...
				
metrics.endTimeTrace( tk );

And here’s the class:

package bb.util
{

    public class Metrics
    {
        // Set this static variable false in your code when you do not want
        // to output the time tracking information but do not want to remove
        // your start and end calls. Alternatively, replace
        // the trace with a logging system.
        public static var showOutput:Boolean = true;

        private const LEN:Number = 10;
        private const PREFIX:String = "_inst_";
        private var hash:Object;
        private static var _instance:Metrics = null;

        /**
         * Constructor.
         */
        public function Metrics()
        {

        }

        /**
         * Singleton accessor.
         *
         * @return The Singleton instance.
         */
        public static function getInstance():Metrics
        {
            if ( !_instance )
            {
                _instance = new Metrics();
                _instance.hash = {};
            }

            return _instance;
        }

        /**
         * Starts a timer.
         *
         * @param name	The name used to identify a particular trace thread.
         * @returns		A String token used to indentify the thread to track. Pass
         * 				this token back when ending the trace.
         * @see			endTimeTrace
         */
        public function startTimeTrace( name:String ):String
        {
            var startTime:Date;
            var newKey:String;

            do
            {
                newKey = getKey( name );
            } while ( this.hash[ newKey ] );

            startTime = new Date();
            this.hash[ newKey ] = { name: name, startTime: startTime };

            return newKey;
        }

        /**
         * Ends a timer.
         *
         * @param key	The token used to identify a particular trace thread which
         * 				is returned with startTimeTrace.
         * @see			startTimeTrace
         * @throws	An error if a corresponding token is not found
         */
        public function endTimeTrace( token:String ):Number
        {
            var rez:Number;
            var endTime:Date = new Date();
            var vo:Object = this.hash[ token ];

            if ( !vo )
            {
                throw new Error( “Metrics error: unknown token: ” + token );
            }

            rez = endTime.getTime() - vo.startTime.getTime();
            log( “Metrics::” + vo.name + ” -> ” + rez / 1000 + ” seconds.” );
            hash[ token ] = null;
            delete hash[ token ];

            return rez;
        }

        // Generates a psuedo-random token for keying
        private function getKey( seed:String ):String
        {
            var newKey:String;
            newKey = seed + PREFIX + StringUtils.generateRandomString( LEN );
            return newKey;
        }

        // Override or edit this to output data however you like
        protected function log( dataString:String ):void
        {
            if ( showOutput )
            {
                trace( dataString );
            }
        }
    }
}
Nov 4

Facebook Share-count Tooltip Using PHP and jQuery/qTip.

For a recent project, I needed a way to show Facebook share counts on a huge number (potentially thousands) of URLs. jQuery to the rescue with help from a plugin sidekick, qTip.

qTip quickly allows you to add tooltips or popup boxes. All you do is call the qtip action on a jQuery selector, and you’re in business. It also lets you call pages dynamically to use as content for the tooptip. And that’s exactly how I am using it here.

jQuery selector runs qTip on the links; qTip populates a tooltip by calling a PHP page; PHP requests Facebook share counts on the href associated with the link. Now, just by assigning that class name to any anchor element, you have a tooltip that shows how many times that link is shared on Facebook.

HTML:

<a href="http://wiki.developers.facebook.com/index.php/API" 
class="shared_link">Facebook API</a>

Javascript:

$(document).ready(function(){
$(".shared_link").each(function(){
$(this).qtip({
content: {
url: 'fetchfbshare.php',
data: {url: $(this).attr('href')},
method: 'post'
},
show: 'mouseover',
hide: 'mouseout'
});
});
});

PHP:

// Encode the URI
$uri = urlencode($_POST['url']);
// Request the stats
$r = file_get_contents('http://api.facebook.com/restserver.php?method=links.getStats&urls='.$uri);
// Parse the XML results
$xml = simplexml_load_string( $r );
// Format output
$shareCount = (string)$xml->link_stat[0]->share_count;
echo "Share Count: $shareCount";

View the sample or download the source. Download the qTip and jQuery libraries. qTip optionally will package them all up for you. The sample files look for the qTip and jQuery files in a /js subdir.

Just think of all the ways you can improve and improvise on this.