Archive for flex

Conditionally enter Debugger in Flex 2

While coding in Flex Builder 2 I found an interesting code hint for a enterDebugger():void
method. This seemed to be another undocumented goodie so I gave it a
try – and it really works. By using the enterDebugger() method in your
code you can invoke the Debugger without setting any breakpoints in
your code. Just place the method call where you want to enter the
Debugger and it will stop at that very line :)

Here’s a quick example:

var n:Number = Math.random();
if (n > 0.9)
{
enterDebugger();
}

This
allows you to write pretty nice dynamic debug code – of course you need
to have the Debug version of Flash Player 9 to get this working. I
haven’t tested yet what happens if the enterDebugger() gets called in
the Release version but I suspect it is just ignored silently.

Original post by Richinternet Blog and software by Elliott Back

Leave a Comment

FLEX LifeCycle

Leave a Comment

datagrid에 대한 subTotals.

http://www.helpqlodhelp.com/blog/archives/000154.html

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute”>
    <mx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
            
            [Bindable]
            private var dataProvider : ArrayCollection = createData();
            
            private function createData() : ArrayCollection
            {
                var result : ArrayCollection = new ArrayCollection();
                for( var i : int = 0; i < 3; i++ )
                {
                    result.addItem( createSimpleRow());
                }
                result.addItem( createSubTotalRow( result ));
                return result;
            }
            
            private function createSimpleRow() : Object
            {
                var result : Object = new Object();
                result.A = randomInt( 10 );
                result.B = randomInt( 10 );
                result.C = randomInt( 10 );
                return result;
            }
            
            private function createSubTotalRow( data : ArrayCollection ) : Object
            {
                var result : Object = new Object();
                result.data = data;
                result.A = createSubTotalObject( data, “A” );
                result.B = createSubTotalObject( data, “B” );
                result.C = createSubTotalObject( data, “C” );
                return result;
            }
            
            private function createSubTotalObject( data : ArrayCollection, property : String ) : Object
            {
                var result : Object = new Object();
                result.toString = function() : String
                {
                    var sum : Number = 0;
                    var length : int = data.length – 1;
                    for( var i : int = 0; i < length; i++ )
                    {
                        var item : Object = data.getItemAt( i );
                        var value : Number = item[ property ];
                        if( ! isNaN( value ))
                        {
                            sum += value;
                        }
                    }
                    return sum.toString();
                }
                return result;
            }
            
            private function randomInt( max : int ) : int
            {
                return Math.floor( Math.random() * max );
            }
        ]]>
    </mx:Script>    
    <mx:DataGrid dataProvider=”{ dataProvider }” editable=”true”/>
</mx:Application>

Leave a Comment

dataGrid의 row 별 색상처리.

Leave a Comment