Changeset 7052

Show
Ignore:
Timestamp:
02/23/08 03:49:15 (5 years ago)
Author:
gyuque
Message:

metro-map: select a station by click.

Location:
lang/actionscript/metro-map
Files:
1 added
3 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/metro-map/FadeController.as

    r7049 r7052  
    5656                         
    5757                        mTarget.alpha = Number(t) / Number(mDivs); 
     58                        mTarget.visible = (mTarget.alpha > 0.1); 
    5859                } 
    5960        } 
  • lang/actionscript/metro-map/SpritePool.as

    r7032 r7052  
    1616                        s.visible = false; 
    1717                        mPool.push(s); 
     18                } 
     19                 
     20                public function getAt(i:int):Sprite 
     21                { 
     22                        return mPool[i]; 
    1823                } 
    1924                 
  • lang/actionscript/metro-map/Viewer.as

    r7049 r7052  
    8383                        mTextInput.width = 200; 
    8484                        mTextInput.addEventListener(Event.CHANGE, onSearchBoxChanged); 
    85                         mTextInput.addEventListener(KeyboardEvent.KEY_DOWN, onSearchBoxKeyDown); 
     85                        addEventListener(KeyboardEvent.KEY_DOWN, onSearchBoxKeyDown); 
    8686                         
    8787                        mCanvas = new MCanvas(900, 500, false, false); 
     
    126126                private function onArrowClick(e:MouseEvent):void 
    127127                { 
    128                          
     128                        if (e.target is ArrowSprite) 
     129                        { 
     130                                mSelectedStation = StationData(ArrowSprite(e.target).userObject); 
     131                                highlightStationList([mSelectedStation]); 
     132                        } 
    129133                } 
    130134                 
     
    215219                private function onSearchBoxKeyDown(e:KeyboardEvent):void 
    216220                { 
    217                         mSelectedStation = null; 
    218221                        if (e.keyCode == 27) 
    219222                        { 
     
    228231                private function onSearchBoxChanged(e:Event):void 
    229232                { 
     233                        mSelectedStation = null; 
    230234                        mOut.text = ""; 
    231235                        var res:Array = mSearch.search(romkan.to_kana(mTextInput.text)); 
     
    254258                { 
    255259                        var poslist:Array = null; 
     260                        var highlighted_list:Array = null; 
    256261 
    257262                        if (stations != null) 
     
    260265 
    261266                                if (stations.length <= 10) 
     267                                { 
    262268                                        poslist = []; 
     269                                        highlighted_list = []; 
     270                                } 
    263271                        } 
    264272                        else 
     
    287295                                                poslist.push(label.x); 
    288296                                                poslist.push(label.y + label.top); 
     297                                                highlighted_list.push(toHighlight[label.title]); 
    289298                                        } 
    290299                                        label.transform.colorTransform = mNoTransform; 
     
    318327                         
    319328                        mArrowPool.show_bulk(poslist); 
     329                        if (highlighted_list) 
     330                                for (var i:int = 0;i < highlighted_list.length;i++) 
     331                                        ArrowSprite(mArrowPool.getAt(i)).userObject = highlighted_list[i]; 
    320332                } 
    321333                 
    322334                private function makeArrowSprite():Sprite 
    323335                { 
    324                         var s:Sprite = new Sprite(); 
     336                        var s:Sprite = new ArrowSprite(); 
    325337                        var g:Graphics = s.graphics; 
    326338