Changeset 14400 for lang/actionscript

Show
Ignore:
Timestamp:
06/22/08 08:22:01 (5 years ago)
Author:
suztomo
Message:

lang/actionscript/FPazzle : implemented eventdispatcher to FlickrConnector?. and fixed a bit bugs.

Location:
lang/actionscript/FPazzle/trunk/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • lang/actionscript/FPazzle/trunk/src/FPazzle.mxml

    r14387 r14400  
    3333                public function init():void { 
    3434                        flc = new FlickrConnector(); 
    35                         setChildIndex(searchbox, numChildren-1); 
    36  
    3735                        Security.loadPolicyFile("http://farm1.static.flickr.com/crossdomain.xml"); 
    3836                        Security.loadPolicyFile("http://farm2.static.flickr.com/crossdomain.xml"); 
     
    5250                        flc.setOnComplete(onFlickrImageComplete); 
    5351                        flc.loadImage(word, 0); 
     52                        flc.addEventListener(FlickrConnector.NOT_FOUND, onNotFound); 
    5453                        searchbox.enabled = false; 
    5554                        CursorManager.setBusyCursor(); 
     
    7170                        searchbox.enabled = true; 
    7271                        board.showPhotoInfo(); 
     72                } 
     73                 
     74                private function onNotFound(event:Event):void 
     75                { 
     76                        Alert.show("No photo found by the keyword", "Photo Not Found"); 
     77                        searchbox.enabled = true; 
     78                        CursorManager.removeBusyCursor(); 
    7379                } 
    7480 
  • lang/actionscript/FPazzle/trunk/src/net/suztomo/FPazzle/FBoard.as

    r14396 r14400  
    66        import flash.events.Event; 
    77        import flash.events.EventDispatcher; 
     8        import flash.events.MouseEvent; 
    89         
    910        import mx.containers.Panel; 
     
    153154                                pieces.getInline(i).deactivate(); 
    154155                        } 
     156                         
     157                        for (i=0; i<groups.length; i++) { 
     158                                (groups[i] as FPieceGroup).deactivate(); 
     159                        } 
    155160                } 
    156161                 
  • lang/actionscript/FPazzle/trunk/src/net/suztomo/FPazzle/FPieceGroup.as

    r14398 r14400  
    2727                        handle = new Sprite; 
    2828                        handle.graphics.beginFill(0x222222, 1); 
    29                         handle.graphics.drawCircle(0, 0, 20); 
    30                         handle.alpha = 0.4; 
     29                        handle.graphics.drawCircle(0, 0, 30); 
     30                        handle.alpha = 0.0; 
    3131                        addChild(handle); 
    3232                        initHandleListener(); 
     
    120120                { 
    121121                        if (pieces.length > 1) handle.alpha = 1; 
     122                        e.stopPropagation(); 
    122123                } 
    123124                 
    124125                private function handleDisappear(e:Event):void 
    125126                { 
    126                         handle.alpha = 0.5; 
     127                        handle.alpha = 0.0; 
     128                        e.stopPropagation(); 
    127129                } 
    128130                 
     
    195197                        } 
    196198                } 
    197  
     199                 
     200                public function deactivate():void 
     201                { 
     202                        handle.removeEventListener(MouseEvent.MOUSE_OVER, handleAppear); 
     203                        handle.removeEventListener(MouseEvent.MOUSE_OUT, handleDisappear); 
     204                        handle.removeEventListener(MouseEvent.MOUSE_DOWN, startDragGroup); 
     205                        handle.removeEventListener(MouseEvent.MOUSE_UP, stopDragGroup); 
     206                } 
    198207        } 
    199208} 
  • lang/actionscript/FPazzle/trunk/src/net/suztomo/FPazzle/FlickrConnector.as

    r14397 r14400  
    55        import com.adobe.webapis.flickr.methodgroups.*; 
    66         
    7         import flash.display.Loader; 
     7        import flash.display.*; 
    88        import flash.events.Event; 
     9        import flash.events.EventDispatcher; 
     10        import flash.events.IEventDispatcher; 
    911        import flash.net.URLRequest; 
    1012        import flash.system.*; 
    11  
     13         
    1214        import mx.controls.*; 
    13  
     15        import mx.core.*; 
    1416        public class FlickrConnector 
    1517        { 
     
    2527                private var keywordCounter:Object; 
    2628                private var keyword:String; 
     29                private var eventDispatcher:EventDispatcher; 
     30                 
    2731                public var tmpPhoto:Photo; 
     32 
     33                public static var NOT_FOUND:String = "searchNotFound"; 
    2834 
    2935                public function FlickrConnector() 
     
    3440                        keywords = new Array(); 
    3541                        keywordCounter = new Object(); 
     42                        eventDispatcher = new EventDispatcher(); 
    3643                } 
    3744                 
     
    6572 
    6673                        if (p == null) { 
    67                                 Alert.show("No photo found by the keyword : "+keywords[keywords.length-1]); 
    6874                                keywords.pop(); 
     75                                eventDispatcher.dispatchEvent(new Event(FlickrConnector.NOT_FOUND)); 
    6976                        } else { 
    7077                                req = new URLRequest(urls[req_index]); 
     
    9299                { 
    93100                } 
     101                 
     102                // Event Listeners 
     103                public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void 
     104                { 
     105                        eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference); 
     106                } 
     107                 
     108                public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void 
     109                { 
     110                        eventDispatcher.removeEventListener(type, listener, useCapture); 
     111                } 
     112                 
     113                public function hasEventListener(type:String):Boolean 
     114                { 
     115                        return eventDispatcher.hasEventListener(type); 
     116                } 
     117                 
     118                public function willTrigger(type:String):Boolean 
     119                { 
     120                        return eventDispatcher.willTrigger(type); 
     121                } 
     122                 
     123                public function dispatchEvent(event:Event):Boolean 
     124                { 
     125                        return eventDispatcher.dispatchEvent(event); 
     126                } 
    94127        } 
    95128}