Archive for 2008

Doesn’t seem like normal behaviour for DataGrid!

Friday, March 21st, 2008

I ran into a problem the other day trying to create a DataGrid that had voting buttons as an itemRenderer. When an action was taken in that cell, the buttons would change, i.e., gray out or light up to show a click occurred. The problem that would happen is that, when I scrolled the list up or down, that column would randomize!

I found posts that talked about solutions for very simple things like a checkbox in a column that did not have any elaborate actionscript behind it, but not to address a component that sat behind the itemRenderer. I figured it out though, and the answer is pretty simple.

I had to add a dataChange function call in the component’s main tag so it would force the cell to rethink it’s status when the grid would scroll.

The main mxml:

<mx:DataGrid id="userGrid" dataProvider="{userData}" sortableColumns="true"
    draggableColumns="false" width="100%" height="100%">
  <mx:columns>
    <mx:DataGridColumn dataField="Topic" width="100" />
    <mx:DataGridColumn id="votecol" dataField="status" headerText="Vote" sortable="true"
        itemRenderer="castVote" width="120" />
    </mx:columns>
</mx:DataGrid>

The castVote component:

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" dataChange="gridMoved()"
    width="100%" height="100%">
<mx:Script>
        <![CDATA[
        import mx.core.Application;
        import mx.events.ListEvent;

        private var myStatus:int = 0;

        private function gridMoved():void{
                if (data != null) {
                        myStatus=data.status;
                }
                doShow(myStatus);
        }

        private function doShow(n:int):void {
                // 0 means already voted, 1 is for, 2 is against
                if (n==0) {
                        buttons.visible=true;
                        v1.visible = v2.visible = false;
                        return;
                }else if (n==1) {
                        v1.visible=true; v2.visible=false;
                        myStatus = n;
                        buttons.visible=false;
                }else if (n==2) {
                        v2.visible=true; v1.visible=false;
                        myStatus = n;
                        buttons.visible=false;
                }
        }

        private function doClick(n:int):void {
                data.status = myStatus = n;
                doShow(n);
        }

        ]]>
</mx:Script>

        <mx:Label id="v1" text="You voted FOR this resolution" visible="false" />
        <mx:Label id="v2" text="You voted AGAINST this resolution!" visible="false" />
        <mx:HBox id="buttons">
                <mx:Button label="YES" click="doClick(1);" />
                <mx:Button label="NO" click="doClick(2);" />
        </mx:HBox>

</mx:Canvas>

My iPhone

Monday, March 17th, 2008

I love my iPhone! Don’t you love yours? I was what you might call an early adopter however, since I got mine in 1996. That’s right, the original iPhone. Luxurious large touch screen, full keyboard, speakerphone, and … 14.4k modem!

Yep, this thing was around a while back, spawned from the labs at National Semiconductor, launched by a startup I worked for, and then sold to Cisco Systems before they kindly gave up the domain name for an undisclosed sum. That domain name used to be registered in my name — I rue the day I assigned it over to Cisco :)

WTF Voicemail

Sunday, March 16th, 2008

My friend Steve threw a party a few weeks back and one of his uninvited guests left him this voicemail the day after. Wait for the image below and click it to hear:

This movie requires Adobe Flash Player -- Download at www.adobe.com

Think you know what the hell this guy is saying? Feel free to comment.

Blog is up finally!

Sunday, March 16th, 2008

I’ve had what you might call a blog since 1998 when back then we just called it a “web page”. I’ve been planning to create an official blog for the past few years but always had better things to do. Since I hadn’t updated my old “blog” for a few years I figured it could wait!

 But wait no longer, here it is!