Show
Ignore:
Timestamp:
10/24/08 02:02:07 (3 months ago)
Author:
genms
Message:

mxmlからプロパティに値を設定していると、初期化に失敗するのを修正
test.mxmlを更新

Location:
lang/actionscript/PagingChunk/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/PagingChunk/trunk/genms/controls/PagingChunk.mxml

    r22001 r22004  
    165165        private function refreshButton():void { 
    166166                var i:int; 
     167 
     168                if (initialized) { 
    167169/* 
    168170trace("pageNum: " + pageNum); 
     
    172174trace("currentChunk: " + currentChunk); 
    173175*/ 
    174                 // Page移動ボタンのenabled 
    175                 backPageButton.enabled = (currentPage > 1); 
    176                 nextPageButton.enabled = (currentPage < pageNum); 
    177  
    178                 // Chunk移動ボタンのenabled 
    179                 firstChunkButton.enabled = (currentChunk >= 2); 
    180                 backChunkButton.enabled = (currentChunk >= 2); 
    181                 nextChunkButton.enabled = (currentChunk <= _chunkNum - 1); 
    182                 lastChunkButton.enabled = (currentChunk <= _chunkNum - 1); 
    183                  
    184                 // 数字ボタンのvisible 
    185                 if (_chunkNum == 0) { 
     176                        // Page移動ボタンのenabled 
     177                        backPageButton.enabled = (currentPage > 1); 
     178                        nextPageButton.enabled = (currentPage < pageNum); 
     179 
     180                        // Chunk移動ボタンのenabled 
     181                        firstChunkButton.enabled = (currentChunk >= 2); 
     182                        backChunkButton.enabled = (currentChunk >= 2); 
     183                        nextChunkButton.enabled = (currentChunk <= _chunkNum - 1); 
     184                        lastChunkButton.enabled = (currentChunk <= _chunkNum - 1); 
     185                         
     186                        // 数字ボタンのvisible 
     187                        if (_chunkNum == 0) { 
     188                                for (i = 0; i < buttonNum; i++) { 
     189                                        numberButtons[i].visible = false; 
     190                                } 
     191                        } 
     192                        else if (_currentChunk == _chunkNum) { 
     193                                var lastChunkButtonNo:int = pageNum - (buttonNum * (currentChunk - 1)); 
     194                                 
     195                                for (i = 0; i < lastChunkButtonNo; i++) { 
     196                                        numberButtons[i].visible = true; 
     197                                } 
     198 
     199                                for (i = lastChunkButtonNo; i < buttonNum; i++) { 
     200                                        numberButtons[i].visible = false; 
     201                                } 
     202                        } 
     203                        else { 
     204                                for (i = 0; i < buttonNum; i++) { 
     205                                        numberButtons[i].visible = true; 
     206                                } 
     207                        } 
     208 
     209                        // 数字ボタンのlabel 
    186210                        for (i = 0; i < buttonNum; i++) { 
    187                                 numberButtons[i].visible = false; 
    188                         } 
    189                 } 
    190                 else if (_currentChunk == _chunkNum) { 
    191                         var lastChunkButtonNo:int = pageNum - (buttonNum * (currentChunk - 1)); 
    192                          
    193                         for (i = 0; i < lastChunkButtonNo; i++) { 
    194                                 numberButtons[i].visible = true; 
    195                         } 
    196  
    197                         for (i = lastChunkButtonNo; i < buttonNum; i++) { 
    198                                 numberButtons[i].visible = false; 
    199                         } 
    200                 } 
    201                 else { 
    202                         for (i = 0; i < buttonNum; i++) { 
    203                                 numberButtons[i].visible = true; 
    204                         } 
    205                 } 
    206  
    207                 // 数字ボタンのlabel 
    208                 for (i = 0; i < buttonNum; i++) { 
    209                         numberButtons[i].label = (_currentChunk - 1) * buttonNum + i + 1; 
     211                                numberButtons[i].label = (_currentChunk - 1) * buttonNum + i + 1; 
     212                        } 
    210213                } 
    211214        } 
     
    215218         */ 
    216219        private function markCurrentPage():void { 
    217                 if (isCurrentPageInCurrentChunk() == 0) { 
    218                         var no:int = currentPage - (_currentChunk - 1) * buttonNum; 
    219                         numberButtons[no - 1].selected = true; 
     220                if (initialized) { 
     221                        if (isCurrentPageInCurrentChunk() == 0) { 
     222                                var no:int = currentPage - (_currentChunk - 1) * buttonNum; 
     223                                numberButtons[no - 1].selected = true; 
     224                        } 
    220225                } 
    221226        } 
     
    225230         */ 
    226231        private function unmarkCurrentPage():void { 
    227                 if (isCurrentPageInCurrentChunk() == 0) { 
    228                         var no:int = currentPage - (_currentChunk - 1) * buttonNum; 
    229                         numberButtons[no - 1].selected = false; 
     232                if (initialized) { 
     233                        if (isCurrentPageInCurrentChunk() == 0) { 
     234                                var no:int = currentPage - (_currentChunk - 1) * buttonNum; 
     235                                numberButtons[no - 1].selected = false; 
     236                        } 
    230237                } 
    231238        } 
     
    253260                var i:int; 
    254261         
    255                 for (i = 0; i < numberButtons.length; i++) { 
    256                         removeChild(numberButtons[i]); 
    257                 } 
    258                 numberButtons = new Array(); 
    259  
    260                 for (i = 0; i < buttonNum; i++) { 
    261                         var button:Button = new Button(); 
    262                         button.name = "b" + (i + 1).toString(); 
    263                         button.percentWidth = 100; 
    264                         button.percentHeight = 100; 
    265                         button.toggle = true; 
    266                         button.styleName = "pcButton"; 
    267                         button.addEventListener(MouseEvent.CLICK, function(event:Event):void  
    268                                 { 
    269                                         numberButtonClickHandler(event, event.target.name.substr(1)); 
    270                                 } 
    271                         ); 
    272                          
    273                         addChildAt(button, 4 + i); 
    274                         numberButtons[i] = button; 
     262                if (initialized) { 
     263                        for (i = 0; i < numberButtons.length; i++) { 
     264                                removeChild(numberButtons[i]); 
     265                        } 
     266                        numberButtons = new Array(); 
     267 
     268                        for (i = 0; i < buttonNum; i++) { 
     269                                var button:Button = new Button(); 
     270                                button.name = "b" + (i + 1).toString(); 
     271                                button.percentWidth = 100; 
     272                                button.percentHeight = 100; 
     273                                button.toggle = true; 
     274                                button.styleName = "pcButton"; 
     275                                button.addEventListener(MouseEvent.CLICK, function(event:Event):void  
     276                                        { 
     277                                                numberButtonClickHandler(event, event.target.name.substr(1)); 
     278                                        } 
     279                                ); 
     280                                 
     281                                addChildAt(button, 4 + i); 
     282                                numberButtons[i] = button; 
     283                        } 
    275284                } 
    276285        } 
  • lang/actionscript/PagingChunk/trunk/test.mxml

    r21457 r22004  
    2727                </mx:Panel> 
    2828                 
    29                 <mx:Panel title="プロパティ変更" height="400"> 
     29                <mx:Panel title="プロパティ変更" height="400" horizontalAlign="center"> 
    3030                        <mx:Form defaultButton="{applyButton}"> 
    3131                                <mx:FormItem label="ページ数"> 
     
    4242                                </mx:FormItem> 
    4343                        </mx:Form> 
     44                         
     45                        <mx:Button id="resetPageButton" label="現在のページを1にリセット" click="pagingChunk.resetCurrentPage();" /> 
    4446                </mx:Panel> 
    4547        </mx:HBox>