Blog

  • Made it to Sydney

    Made it into Sydney, Australia last night at about 10:30pm. Coding this morning until I find an outlet converter, we checkout, or this laptop battery dies… whichever comes first. We check out of this airport hotel at 11am, and catch a bus to catch a bus to Bondi Beach where our hotel #2 of 5 is. I think I’ve adjusted significantly quicker to the time change compared to 2 years ago… it just took 3 days of little to no sleep to prepare.

    Anyway, LOT’s of work to do before MXDU. No rest for the weary. WOOSHAA!!!

  • Take the Flex Component Survey

    Lucian Beebe, Flex Product Manager has a survey he’d like us all to take.

    “This is your chance to steer our development efforts to build the Flex components you need and to make it easy on you to develop Flex applications.

    It’ll only take three minutes and it will help us all out a lot. You won’t be put on any lists or contacted in any way unless *you* want to talk to someone about your thoughts for components development.

    Thank you”

    Take the quick survey!

  • ViewStack in Flash

    As the tasks, goals, and due dates pile up, I wonder what the heck I was thinking in even believing I could accomplish all of the things set before me. I fear boredom worse than death, and this has formed a masochistic behavior in setting unattainable goals for myself. I don’t necessarely get all that frustrated not attaining them all, because I’d much rather be swamped then wondering what there was to do.

    A class I thought I’d share is the ViewStack. I implemented my own version in Flash. The ViewStack is one of the hot container classes Flex has. It basically creates a bunch of components in itself, and lets you toggle their visibility. What this acheives is an extremely easy way to create wizards and other light weight, multi-step processes. Mine doesn’t compete with Flex’; there is a lot more that the Flex version has both implemented in it, and underneath from the inheritance tree, but mine serviced fine for lightweight component toggling. I built mine from scratch and didn’t really compare to the actual AS file, so I’m sure mine pales in comparison, but hopefully this’ll give you a better appreciation of what Flex has to offer, and how implementing this, already built in Flex, stuff is kind of… uncool to do in Flash. I’d rather just have an SWC that worked, and legally. It’ll be challenging to see how I handle transitions…

    Anyway, to get it to work, you’ll need 1 additional method in your mx.core.View class:

    function getChildIndex(child:UIObject):Number
    {
            var i:Number = numChildren;
            while(i--)
            {
                    if(getChildAt(i) == child)
                    {
                            return i;
                    }
            }
            return null;
    }
    

    Haven’t hardcore tested the above function, and it’s different than Flex’ implementation (which I’m sure has been QA tested), so use at your own risk.

    Then, the ViewStack class:

    /*
    class: ViewStack
    by Jesse Warden
    jesse@jessewarden.com
    
    The ViewStack implementation I've done
    is a gross simplification on the Flex one.
    Basically, it just takes controls,
    and controls their visibility.
    
    If you want to buy me Flex, send me an email!
    
    */
    
    import mx.core.View;
    import mx.core.UIObject;
    
    class ViewStack extends View
    {
            // group: UIComponent variables
            static var symbolName:String = "ViewStack";
            static var symbolOwner:Object = ViewStack;
            public var className:String = "ViewStack";
            
            // group: private
            private var _selectedChild:UIObject;
            private var _selectedIndex:Number;
            
            // group: getter/settters
            // ---------------------------------------------------------------------------
            public function get selectedChild():UIObject
            {
                    return getChildAt(selectedIndex);
            }
            
            // ---------------------------------------------------------------------------
            public function set selectedChild(obj:UIObject):Void
            {
                    _selectedIndex = getChildIndex(obj);
                    refresh();
            }
            
            // ---------------------------------------------------------------------------
            public function get selectedIndex():Number
            {
                    return _selectedIndex;
            }
            
            // ---------------------------------------------------------------------------
            public function set selectedIndex(val:Number):Void
            {
                    _selectedIndex = val;
                    _selectedChild = selectedChild;
                    refresh();
            }
            
            // group: methods
            // ---------------------------------------------------------------------------
            function ViewStack()
            {
            }
            
            // ---------------------------------------------------------------------------
            public function init():Void
            {
                    super.init();
                    
                    _selectedIndex = 0;
            }
            
            // ---------------------------------------------------------------------------
            private function doLayout():Void
            {
                    super.doLayout();
                    refresh();
            }
            
            // ---------------------------------------------------------------------------
            private function addLayoutObject(obj:Object):Void
            {
                    refresh();
            }
            
            // ---------------------------------------------------------------------------
            private function refresh():Void
            {
                    var i:Number = numChildren;
                    while(i--)
                    {
                            var child = getChildAt(i);
                            child.setVisible(false);
                    }
                    
                    var selChild = getChildAt(selectedIndex);
                    selChild.setVisible(true);
            }
    }
    

    Finally, example usage (drag Button and TextArea components into your Library, then put your ViewStack MovieClip on stage, and name it “mc”):

    mc.createChild(mx.controls.Button, "cal1");
    mc.createChild(mx.controls.TextArea, "assign1");
    
    function onKeyDown()
    {
            switch(Key.getCode())
            {
                    case Key.LEFT:
                    mc.selectedChild = mc.cal1;
                    break;
                    
                    case Key.RIGHT:
                    mc.selectedChild = mc.assign1;
                    break;
                    
                    case Key.UP:
                    mc.selectedIndex = 0;
                    break;
                    
                    case Key.DOWN:
                    mc.selectedIndex = 1;
                    break;
            }
    }
    
    Key.addListener(this);
    

    It is not as efficient as Flex b/c it doesn’t implement a creationPolicy, doesn’t resize to the content, and a ton of other things… but the concept is cool, so far works in a prototype.

    The weird comments are for NaturalDocs. I got it to work, and really dig how easy it is to add documentation to my code without crazy comments. Once I got a bat file setup, it was really easy to recompile my documentation after a code change… and NaturalDocs is smart enough only to recompile the changed class. Good stuff!

  • Zombie Nation: Use Firefox to Prevent Terrorism

    That was the informative speech I gave Monday night in class. Got an A!

    Additionally, open book test we took last Wednesday, got the highest grade in the class, a 98 (out of 100). The 2 I got wrong were done because I wasn’t paying attention to the fine print of the question. Being considered wrong because I was tricked was frustrating… but I still won.

    It was really nice after my speech and during others’ intermissions to have people ask me questions about “Do webpages still work correctly?” and where do you get it, etc. We got the teacher to tell stories about computer happenings, like he sometimes does. He’s a good storyteller and has a lot of them since he used to be a cop, and a PR dude for some big company.

    Anyway, I think I hopefully scored more converts and got a good grade doing it.