Flex3.0&AS3 2008. 12. 1. 14:05

updateDisplayList() 알아보기


updataDisplayList() 메서드는 스타일에 관련 셋팅을 변경하거나 설정할때 호출되어지는 메서드이다.

플렉스에서는 addChild()를 하여 컨터이너에 콤포넌트를 추가하게되면 자동적으로 invalidateDisplayList()메서드를 호출하게 되고 이 메서드가 호출된후에 updataDisplayList()가 호출되어 시각화되게 되는것이다.

따라서 UIComponent 클래스를 구현한 모든 클래스에서는 스타일변경이 필요한경우에는 위의 메서드를 오버라이드해서 작업을 해주면된다.

protected function updateDisplayList(unscaledWidth:Number,
    unscaledHeight:Number):void

unscaledWidth Specifies the width of the component, in pixels, in the component's coordinates, regardless of the value of the scaleX property of the component. This is the width of the component as determined by its parent container.

unscaledHeight Specifies the height of the component, in pixels, in the component's coordinates, regardless of the value of the scaleY property of the component. This is the height of the component as determined by its parent container.

Scaling occurs in Flash Player, after updateDisplayList() executes. For example, a component with an unscaledHeight value of 100, and with a scaleY property of 2.0, appears 200 pixels high in Flash Player.

/*아래 일부코드는 updateDisplayList()메서드를 오버라이드한 일부 첨부파일중 일부 코드이다.*/
 override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
         {
            super.updateDisplayList(unscaledWidth, unscaledHeight);

            if (data != null && listData != null && data[DataGridListData(listData).dataField] < 0)
            {
                 setStyle("color", 0xFF0000);
             }
             else
             {
                 setStyle("color", 0x009900);
             }

        }

자세한 내용은 아래 url을 참조
http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=ascomponents_advanced_148_16.html


Sample>