PhxFPUG Assets

If you’re coming to the Phoenix Flash Platform User Group meeting tonight (and I hope you are!) or you are there now, or maybe you heard about how cool it was then these things might be helpful for you.

The two tools we’ll be talking about are RobotLegs and Swiz.  Here are the links to their respective locations on the interweb.

http://www.robotlegs.org/

http://swizframework.org/

If you’re playing along then you might want to download the projects I’ll be demoing.  Please keep in mind that these projects attempt to demonstrate how these tools work; NOT NECESSARILY BEST PRACTICES.  They are only meant to give you a basic understanding of the principals.

FPUG Projects

If you just want to download the .swc files (which are included in the projects as necessary) then you can grab them here.

RobotLegs 1.0.2

Swiz 0.6.4 (for Flex 3)

Facebook AS3 lib 3.4

And if you want to “borrow” my Facebook App key and secret you can use these values (they are going to get changed after tonight and it’s a sandbox app anyway so you won’t be able to do anything fun with it anyway).

API Key: abcdefghijlkmnopqrstuvwxyz

Secret: nowiknowmyabcsnexttimewontyousingwithme

Lastly, if you care to follow along with my slides you can download those here.  You probably won’t get much without me standing in front of them being awesome, but you are welcome to them if you want ‘em.

PFUG DI Preso

Klok – This stuff shouldn’t be free

Klok 2I recently started testing the new version of Klok.  Klok is an Air app used to track your time.  Version 1.5 has been out for quite a while and I didn’t work without it running.  I tend to jump around my projects quite a bit and I usually have to keep track of how much time I spend on which tasks, etc.  Klok has always been a great tool to let me do that.  And it’s a free application!  Version 1.5 is available now and 2.0 is under active development and has made some FANTASTIC improvements.  This thing is, it SHOULDN’T be a free application.  I really think it’s that good.  I won’t go over all of the features that make it awesome cause this is a short post and I’ve got lots of actual work to do (yes, I’m logging the time I’m spending to write this blog post).  There’s lots of great time keeping apps out there and I’ve used lots of them.  This is the one I like the best.

Right now you can’t download the 2.0 beta unless you donate to the project.  So ACT NOW while the application isn’t free.  It’s totally worth it.

Now back to the work I get paid to do . . .

FlashVar manager using Swiz or RobotLegs

I use FlashVars a lot. Sometimes I need to open or launch something from my application on startup. Sometimes I just need to know some authentication credentials and that’s the way they are passed to me. Something that I have found that has made this easier for me has been to create a FlashVarManager for my projects.

FlashVars are gleaned from a LoaderInfo object and it is just a dynamic Object. (loaderInfo.properties to be exact). But you probably knew that. Being a fan of strongly typedness I usually create some getters on my manager that will fetch a specific flashVar from the .properties object and if there isn’t one give me a default. Since I always did this for Flex projects the most straightforward way to grab what I needed was through the Application instance. My manager would look something like this.

package com.pbking.demo
{
  public class FlashVarManager
  {
    private static var:_instance:FlashVarManager;
    private var _flashVars:Object;    

    public static function getInstance():FlashVarManager
    {
      if(!_instance)
      {
        _instance = new FlashVarManager();
        _flashVars = Application(Application.application).loaderInfo.properties;
      }
      return _instance;
    }

    public function get flashVars():Object
    {
      return _flashVars;
    }

    public function get specificFlashVarValue():String
    {
      if(flashVars[’specificValue’] != undefined)
        return flashVars[’specificValue’];
      else
        return "someDefaultValue";
    }
  }
}

Something like that.

So if ever my flashVars had to change I could just change this class. I will often perform logic in here too; sometimes create a faux “flashVar” that is based on a number of flashVars. I find it pretty handy.

But I’m trying to eliminate Singletons wherever I can. Not necessarily Singletons in the “one instance exists” sense, but more in the .getInstance() sense. RobotLegs and Swiz are really helping me out with that. But how to construct my FlashVarManager with those tools? How do you get to the loaderInfo of the app (without using the messy Application() hack)?
Read more

Signals may spell the death to my Commands as I know them

Back when I wrote my Command library I was doing a lot of calling of commands.  It actually stems from the Commands/Delegates I created for the Facebook AS3 API (which have since been removed; which I think is a shame).  Essentially the greatest benefit I got from my commands with the ability to do this:

commandInstance.addCallback(onComplete);
function onComplete(commandInstance:CommandClass):void
{ // do stuff }
 

instead of this:

commandInstance.addEventListener(Event.COMPLETE, onComplete);
function onComplete(e:Event):void
{
  var commandInstance:CommandClass = e.target as CommandClass;
  commandInstance.removeEventListener(Event.COMPLETE, onComplete);
  //NOW I can do stuff
}
 

That got rid of a lot of code for me and made me very happy.

Boss: Jason, how many lines of code did you write today?
Me: (proudly) Negative two-hundred-sixty-nine!

Just kidding. My boss has never asked me how many lines of code I wrote.
Read more

Swiz vs RobotLegs LIVE!

Since I began my DI framework journey I have used these two tools a lot.  I’ve gone back and forth and back and forth over which I like better.  Strangely, it’s usually the one I’m NOT currently using that I favor.  The things I miss always stand out when I can’t use them.

Well on Wed Jan 27th I’m going to be hashing these two frameworks out live at the Phoenix Flash Platform User Group.  For those unfamiliar with Dependency Injection frameworks I’ll go over the basics of how to get started with both Swiz and RobotLegs and how they are the same.  It will be a “lab” session and my plan is to walk everyone who is interested through the process of building a working sample.  Check back here the day of the presentation for links and resources to help us along.  It MAY help to have a Facebook account and SOME familiarity with building Facebook apps with the AS3 API.  I’m thinking of doing that as the example apps.  What do you think?

Then I’m going to talk about how the two frameworks are different.  I’m going to try very hard to be impartial.  I LOVE both of these frameworks.  There are a few points about them that I’m planning to go over (besides the basics of how to set them up).

  • What is a Context and why does it make my hair look better?
  • Will Swiz 1.0 alpha make by teeth whiter than 0.6.4?
  • What if I want to process my own MetaData?  Can any of this help me?
  • I REALLY like to use PatternX instead of Pattern42 when dealing with my views.  Can I do that?
  • Commands vs Controllers on WWF SmackDown.  Who’s logic will win?
  • Does/should a 1.0 version really matter? (Yes, I want to talk about this one, but probably only AFTER the meeting once the booze has started flowing).

My question to you, the concerned reader is what else should I discuss?  Are there any benefits or differences that you would like to see that I point out?  Please leave your comments here (in a timely manner) and I will do my best to get the points into the presentation.  I know there are other similar frameworks out there (Parsley is actually one I like a lot too) but these are the two I use daily and am most familiar with.  They are the ones I decided to put into my toolbox so they are the ones I will talk about.

I will try to tape the presentation or at least make the slides available so maybe that can help others out there who want to get started.

Next Page »