Changeset 14965 for lang/actionscript
- Timestamp:
- 07/01/08 02:22:00 (5 months ago)
- Location:
- lang/actionscript/FPazzle/trunk/src
- Files:
-
- 5 modified
-
FPazzle.css (modified) (2 diffs)
-
FPazzle.mxml (modified) (7 diffs)
-
net/suztomo/FPazzle/FBoard.as (modified) (2 diffs)
-
net/suztomo/FPazzle/FPiece.as (modified) (3 diffs)
-
net/suztomo/FPazzle/FlickrConnector.as (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/actionscript/FPazzle/trunk/src/FPazzle.css
r14276 r14965 10 10 paddingTop: 5; 11 11 paddingBottom: 5; 12 fontSize: 14; 12 13 } 13 14 … … 20 21 } 21 22 23 .note 24 { 25 paddingLeft: 20; 26 } 27 22 28 .photoInfo 23 29 { 24 30 paddingTop: 50px; 25 fontSize: 12 px;31 fontSize: 12; 26 32 } 33 34 .imageUrl 35 { 36 paddingTop: 10; 37 paddingLeft: 50; 38 fontSize: 12; 39 } 40 41 .giveup 42 { 43 right: 20px; 44 } -
lang/actionscript/FPazzle/trunk/src/FPazzle.mxml
r14949 r14965 1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();"> 3 <mx:HBox styleName="keyword"> 4 <mx:HBox enabled="true" id="searchbox"> 5 <mx:TextInput id="keyword" styleName="input" focusIn="onSearchFocus();" focusOut="onSearchLeave();" /> 6 <mx:Button id="keywordSubmit" label="Search" click="flickrStart();" /> 3 <mx:VBox width="100%" > 4 <mx:HBox styleName="keyword" width="90%"> 5 <mx:HBox enabled="true" id="searchbox" width="100%"> 6 <mx:TextInput id="keyword" styleName="input" focusIn="onSearchFocus();" focusOut="onSearchLeave();" /> 7 <mx:Button id="keywordSubmit" label="Search" click="flickrStart();" /> 8 </mx:HBox> 9 <mx:Label id="permalink" selectable="true" /> 10 <mx:Button id="giveUp" label="Give Up..." click="onGiveUp();" styleName="giveup" visible="false" /> 7 11 </mx:HBox> 8 <mx:Label id="imageUrl" selectable="true" />9 <mx:Label id="permalink" selectable="true" />10 </mx: HBox>12 <mx:Label id="keywordNote" text='e.g. "flower", "sea", "haruhi" etc.' styleName="note" /> 13 <mx:Label id="imageUrl" selectable="true" styleName="imageUrl" text="hoghoge" /> 14 </mx:VBox> 11 15 12 16 <mx:Script> … … 60 64 61 65 public function flickrStart():void { 62 if (keyword.text.length < 5) {63 Alert.show("Please Input 5or more charactors word", "Too short keyword");66 if (keyword.text.length < 3) { 67 Alert.show("Please Input 3 or more charactors word", "Too short keyword"); 64 68 return; 65 69 } 66 70 var word:String = keyword.text; 71 imageUrl.htmlText = ""; 67 72 flc.setOnComplete(onFlickrImageComplete); 68 73 flc.loadImage(word, 0); … … 75 80 { 76 81 img = event.target.content.bitmapData; 77 board = new FBoard( 2, 2, img);82 board = new FBoard(3, 3, img); 78 83 board.addEventListener(FBoard.BOARD_COMPLETE, onBoardComplete); 79 84 addChild(board); 80 85 board.photo = flc.tmpPhoto; 81 targetUrl = "http://flickr.com/photos/"+board.photo.ownerId+"/"+board.photo.id; 82 imageUrl.htmlText = '<font color="#61D2FF"><a target="_blank" href="'+targetUrl+'" >'+ 'View current photo on Flickr</a></font>'; 83 /* permalink.htmlText = ' <font color="#61D2FF"><a target="_blank" href="http://suztomo.net/fp/?url='+board.photo.url+'">' 84 + 'Permalink to Pazzle</a></font>';*/ 86 giveUp.visible = true; 87 85 88 board.createPieces(); 86 89 … … 95 98 bgImage.scaleY = 0.6; 96 99 bgImage.x = 50; 97 bgImage.y = 1 00;100 bgImage.y = 130; 98 101 if (i != null) { 99 102 i.addCustomEventListener("moved", onMiniImageMoved); … … 137 140 searchbox.enabled = true; 138 141 board.showPhotoInfo(); 142 targetUrl = "http://flickr.com/photos/"+board.photo.ownerId+"/"+board.photo.id; 143 imageUrl.htmlText = '<font color="#61D2FF"><a target="_blank" href="'+targetUrl+'" >'+ '>> View current photo on Flickr</a></font>'; 139 144 } 140 145 … … 148 153 private function onPressKey(event:KeyboardEvent):void 149 154 { 150 if (event.keyCode == 13 && searchbox.enabled) keywordSubmit.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); 155 if (event.keyCode == 13) { 156 if (searchbox.enabled) { 157 keywordSubmit.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); 158 } else if (giveUp.visible == true) { 159 giveUp.dispatchEvent(new MouseEvent(MouseEvent.CLICK)); 160 } 161 } 151 162 } 152 163 … … 162 173 } 163 174 175 private function onGiveUp():void 176 { 177 giveUp.visible = false; 178 if (board) board.showAnswer(); 179 } 180 164 181 165 182 ]]> -
lang/actionscript/FPazzle/trunk/src/net/suztomo/FPazzle/FBoard.as
r14660 r14965 22 22 private static var answerDiff:Number = 2; 23 23 private var eventDispatcher:EventDispatcher; 24 private var numAnsweredPieces:int = 0;; 24 25 25 26 public var p_width:Number, p_height:Number; … … 173 174 } 174 175 176 public function showAnswer():void 177 { 178 var g:FPieceGroup = groups[0]; 179 g.x = p_width*x_num * 0.4 + 300; 180 g.y = 120; 181 182 for (var j:uint=0; j<groups.length;j++) { 183 (groups[j] as FPieceGroup).deactivate(); 184 } 185 186 for (var i:uint=0; i<pieces.length; i++) { 187 g.putNewPiece(pieces.getInline(i) as FPiece); 188 } 189 190 slideNextPiece(); 191 } 192 193 public function slideNextPiece():void 194 { 195 if (numAnsweredPieces >= pieces.length) { 196 checkAnswer(); 197 return; 198 } 199 200 var p:FPiece = pieces.getInline(numAnsweredPieces) as FPiece; 201 p.slideTo((numAnsweredPieces % x_num) * p_width, Math.floor(numAnsweredPieces / x_num) * p_height); 202 numAnsweredPieces += 1; 203 } 204 175 205 // Event Listeners 176 206 public override function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void -
lang/actionscript/FPazzle/trunk/src/net/suztomo/FPazzle/FPiece.as
r14949 r14965 7 7 import flash.text.*; 8 8 9 import mx.effects.Rotate;10 9 import mx.managers.*; 11 10 … … 25 24 private var idNumber:TextField; 26 25 private var rotateController:RotateController; 26 private var toX:Number, toY:Number; 27 27 28 28 public var x_index:uint, y_index:uint; … … 175 175 removeChild(rotateController); 176 176 } 177 178 public function slideTo(_toX:Number, _toY:Number):void 179 { 180 toX = _toX; 181 toY = _toY; 182 addEventListener(Event.ENTER_FRAME, _slideTo); 183 } 184 185 private function _slideTo(e:Event):void 186 { 187 x += (toX - x)/ 6; 188 y += (toY - y)/ 6; 189 190 if (Math.abs(toX - x) < 5) { 191 x = toX; 192 y = toY; 193 rotation = 0; 194 removeEventListener(Event.ENTER_FRAME, _slideTo); 195 board.slideNextPiece(); 196 } 197 } 177 198 } 178 199 } -
lang/actionscript/FPazzle/trunk/src/net/suztomo/FPazzle/FlickrConnector.as
r14429 r14965 8 8 import flash.events.Event; 9 9 import flash.events.EventDispatcher; 10 import flash.events.IEventDispatcher;11 10 import flash.net.URLRequest; 12 11 import flash.system.*; … … 28 27 private var keyword:String; 29 28 private var eventDispatcher:EventDispatcher; 29 private var photoRecorder:Array; 30 30 31 31 public var tmpPhoto:Photo; … … 41 41 keywordCounter = new Object(); 42 42 eventDispatcher = new EventDispatcher(); 43 photoRecorder = new Array(); 43 44 } 44 45 … … 60 61 var p:Photo; 61 62 urls = new Array(); 63 var url:String; 62 64 var req_index:uint = (keywordCounter[keyword] == undefined)? 63 65 0 : keywordCounter[keyword]; 64 66 65 for (var i:uint=0; i< =req_index; i++) {67 for (var i:uint=0; i<ps.length; i++) { 66 68 p = ps[i]; 67 if (p) urls.push(makePhotoURL(p.id.toString(), p.server.toString(), p.secret)); 69 if (photoRecorder.indexOf(p.id) == -1) { 70 // urls.push(makePhotoURL(p.id.toString(), p.server.toString(), p.secret)); 71 url = makePhotoURL(p.id.toString(), p.server.toString(), p.secret) 72 photoRecorder.push(p.id); 73 break; 74 } 68 75 } 69 76 … … 75 82 eventDispatcher.dispatchEvent(new Event(FlickrConnector.NOT_FOUND)); 76 83 } else { 77 req = new URLRequest(url s[req_index]);84 req = new URLRequest(url); 78 85 var lc:LoaderContext = new LoaderContext(true); 79 86 … … 86 93 } 87 94 88 tmpPhoto = p s[req_index] as Photo;89 tmpPhoto.url = url s[req_index];95 tmpPhoto = p; 96 tmpPhoto.url = url; 90 97 } 91 98 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)