Your SlideShare is downloading. ×
Ssaw08 1021
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Ssaw08 1021

1,645
views

Published on


0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,645
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
52
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. <?xml version=quot;1.0quot; encoding=quot;utf-8quot; ?> <rsp stat=quot;okquot;> <photos page=quot;1quot; pages=quot;4quot; perpage=quot;100quot; total=quot;360quot;> <photo id=quot;2878963976quot; owner=quot;64925044@N00quot; secret=quot;78ff42e98cquot; server=quot;3199quot; farm=quot;4quot; title=quot;080927_ quot; ispublic=quot;1quot; isfriend=quot;0quot; isfamily=quot;0quot; /> <photo id=quot;2878130929quot; owner=quot;64925044@N00quot; secret=quot;53680e4271quot; server=quot;3027quot; farm=quot;4quot; title=quot;080927_ quot; ispublic=quot;1quot; isfriend=quot;0quot; isfamily=quot;0quot; /> <photo id=quot;2878130717quot; owner=quot;64925044@N00quot; secret=quot;b3f9c8d178quot; server=quot;3232quot; farm=quot;4quot; title=quot;080927_ quot; ispublic=quot;1quot; isfriend=quot;0quot; isfamily=quot;0quot; /> ... </photos> </rsp>
  • 2. as3flickrlib
  • 3. package { import com.adobe.webapis.flickr.*; import com.adobe.webapis.flickr.events.*; import com.adobe.webapis.flickr.methodgroups.*; import flash.display.*; import flash.events.*; import flash.net.*; import flash.text.*; [SWF(backgroundColor=quot;#888888quot;)] public class FlickrTest extends Sprite { //-------------------------------------- // CLASS CONSTANTS //-------------------------------------- private static const UID:String = quot;Flickr API_KEY quot;; //-------------------------------------- // CONSTRUCTOR //-------------------------------------- public function FlickrTest() { // stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE;
  • 4. //Flickr API var fls:FlickrService = new FlickrService(UID); // fls.addEventListener(FlickrResultEvent.PHOTOS_SEARCH, onFlickrSearchComplete); // quot;Tamabiquot; fls.photos.search(quot;quot;, quot;Tamabiquot;, quot;anyquot;, quot;quot;); } //-------------------------------------- // PRIVATE VARIABLES //-------------------------------------- //-------------------------------------- // GETTER/SETTERS //-------------------------------------- //-------------------------------------- // PUBLIC METHODS //-------------------------------------- //-------------------------------------- // EVENT HANDLERS //-------------------------------------- // private function onFlickrSearchComplete(event:FlickrResultEvent):void {
  • 5. // var photos:Array = PagedPhotoList( event.data['photos'] ).photos; // for ( var i:int = 0; i < photos.length; i++ ) { // var curPhoto:Photo = photos[i]; // URL var photoUrl:String = quot;http://farmquot; + curPhoto.farmId + quot;.static.flickr.com/quot; + curPhoto.server + quot;/quot; + curPhoto.id + quot;_quot; + curPhoto.secret + quot;.jpgquot;; // trace(quot;photo[quot; + i + quot;] : quot; + photoUrl); } } //-------------------------------------- // PRIVATE & PROTECTED INSTANCE METHODS //-------------------------------------- } }
  • 6. package { import com.adobe.webapis.flickr.*; import com.adobe.webapis.flickr.events.*; import com.adobe.webapis.flickr.methodgroups.*; import flash.display.*; import flash.events.*; import flash.net.*; import flash.text.*; [SWF(backgroundColor=quot;#888888quot;)] public class FlickrTest extends Sprite { //-------------------------------------- // CLASS CONSTANTS //-------------------------------------- private static const UID:String = quot;API_KEYquot;; //-------------------------------------- // CONSTRUCTOR //-------------------------------------- public function FlickrTest() { // stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE;
  • 7. //Flickr API var fls:FlickrService = new FlickrService(UID); // fls.addEventListener(FlickrResultEvent.PHOTOS_SEARCH, onFlickrSearchComplete); // quot;Tamabiquot; fls.photos.search(quot;quot;, quot;Tamabiquot;, quot;anyquot;, quot;quot;); } //-------------------------------------- // PRIVATE VARIABLES //-------------------------------------- //-------------------------------------- // GETTER/SETTERS //-------------------------------------- //-------------------------------------- // PUBLIC METHODS //-------------------------------------- // public function swapToTop(img:ImageLoader):void { addChild(img); }
  • 8. //-------------------------------------- // EVENT HANDLERS //-------------------------------------- // private function onFlickrSearchComplete(event:FlickrResultEvent):void { // var photos:Array = PagedPhotoList( event.data['photos'] ).photos; // for ( var i:int = 0; i < photos.length; i++ ) { // var curPhoto:Photo = photos[i]; // URL var photoUrl:String = quot;http://farmquot; + curPhoto.farmId + quot;.static.flickr.com/quot; + curPhoto.server + quot;/quot; + curPhoto.id + quot;_quot; + curPhoto.secret + quot;.jpgquot;; // trace(quot;photo[quot; + i + quot;] : quot; + photoUrl); //ImagLoader var imgLoader:ImageLoader = new ImageLoader(photoUrl, this); addChild(imgLoader); } }
  • 9. //-------------------------------------- // PRIVATE & PROTECTED INSTANCE METHODS //-------------------------------------- } }
  • 10. // ImageLoader.as package { import flash.display.*; import flash.net.*; import flash.events.*; import flash.text.*; import flash.filters.DropShadowFilter; import gs.TweenMax; import gs.easing.*; public class ImageLoader extends Sprite { //-------------------------------------- // CLASS CONSTANTS //-------------------------------------- //-------------------------------------- // CONSTRUCTOR //-------------------------------------- public function ImageLoader(url:String, main:Object) { // _main = main; scaleX = 0; scaleY = 0; buttonMode = true;
  • 11. // filters = [new DropShadowFilter(0,0,0,0.5,16,16)]; //loader _imgLoader = new Loader(); // _imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoaded); // this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); this.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); // var urlReq:URLRequest=new URLRequest(url); _imgLoader.load(urlReq); } //-------------------------------------- // PRIVATE VARIABLES //-------------------------------------- private var _main:Object; private var _url:String; private var _imgLoader:Loader; private var _perFld:TextField; private var _width:Number; private var _height:Number;
  • 12. //-------------------------------------- // GETTER/SETTERS //-------------------------------------- //-------------------------------------- // PUBLIC METHODS //-------------------------------------- //-------------------------------------- // EVENT HANDLERS //-------------------------------------- // private function onLoaded(event:Event):void { // var info:LoaderInfo = LoaderInfo(_imgLoader.contentLoaderInfo); _imgLoader.width = info.width / 4; _imgLoader.height = info.height / 4; _imgLoader.x = -_imgLoader.width / 2; _imgLoader.y = -_imgLoader.height / 2; // x = stage.stageWidth / 2; y = stage.stageHeight / 2; // drawBaseRect();
  • 13. // addChild(_imgLoader); // _main.swapToTop(this); // TweenMax.to(this, 1, {scaleX:1, scaleY:1, ease:Elastic.easeOut}); TweenMax.to(this, 1, {rotation:Math.random() * 360 - 180, ease:Quint.easeOut}); TweenMax.to(this, 1, {x:Math.random() * stage.stageWidth, y:Math.random() * stage.stageHeight, ease:Quint.easeOut}); } // private function onMouseDown(event:MouseEvent):void { // this.startDrag(true); // _main.swapToTop(this); // TweenMax.to(this, 1, {scaleX:4.0, scaleY:4.0, ease:Elastic.easeOut}); TweenMax.to(this, 0.2, {rotation:0, ease:Quint.easeOut}); }
  • 14. // private function onMouseUp(event:MouseEvent):void { this.stopDrag(); TweenMax.to(this, 1, {rotation:Math.random() * 360 - 180, scaleX:1.0, scaleY:1.0, ease:Quint.easeOut}); } //-------------------------------------- // PRIVATE & PROTECTED INSTANCE METHODS //-------------------------------------- // private function drawBaseRect():void { var rect:Sprite = new Sprite(); rect.graphics.beginFill(0xFFFFFF); rect.graphics.drawRect(-3, -3, _imgLoader.width + 6, _imgLoader.height + 6); rect.x = -_imgLoader.width / 2; rect.y = -_imgLoader.height / 2; addChild(rect); } } }
  • 15. package { import com.adobe.webapis.flickr.*; import com.adobe.webapis.flickr.events.*; import com.adobe.webapis.flickr.methodgroups.*; import flash.display.*; import flash.events.*; import flash.net.*; import flash.text.*; [SWF(backgroundColor=quot;#888888quot;)] public class FlickrSearch extends Sprite { //-------------------------------------- // CLASS CONSTANTS //-------------------------------------- private static const UID:String = quot;API_KEYquot;; //-------------------------------------- // CONSTRUCTOR //-------------------------------------- public function FlickrSearch() { // stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE;
  • 16. // _photoLayer = new Sprite(); addChild(_photoLayer); //GUI _guiLayer = new Sprite(); addChild(_guiLayer); // createUI(); } //-------------------------------------- // PRIVATE VARIABLES //-------------------------------------- private var _photoLayer:Sprite; // private var _guiLayer:Sprite; //UI private var _headerBackground:Sprite; //UI private var _tf:TextField; // private var _searchButton:SimpleButton; // private var _resetButton:SimpleButton; // private var _fls:FlickrService; //Flickr private var _photos:Photos; //
  • 17. //-------------------------------------- // GETTER/SETTERS //-------------------------------------- //-------------------------------------- // PUBLIC METHODS //-------------------------------------- // public function swapToTop(img:ImageLoader):void { _photoLayer.addChild(img); } //-------------------------------------- // EVENT HANDLERS //-------------------------------------- //search private function onSearchButtonClick(event:Event):void { _fls = new FlickrService(UID); _fls.addEventListener( FlickrResultEvent.PHOTOS_SEARCH, onFlickrSearchComplete); _fls.photos.search(quot;quot;, _tf.text, quot;anyquot;, quot;quot;); }
  • 18. // private function onResetButtonClick(event:Event):void { removeChild(_photoLayer); _photoLayer = new Sprite(); addChild(_photoLayer); addChild(_guiLayer); } // private function onFlickrSearchComplete(event:FlickrResultEvent):void { // var photos:Array = PagedPhotoList( event.data['photos'] ).photos; // for ( var i:int = 0; i < photos.length; i++ ) { // var curPhoto:Photo = photos[i]; // URL var photoUrl:String = quot;http://farmquot; + curPhoto.farmId + quot;.static.flickr.com/quot; + curPhoto.server + quot;/quot; + curPhoto.id + quot;_quot; + curPhoto.secret + quot;.jpgquot;; //ImagLoader var imgLoader:ImageLoader = new ImageLoader(photoUrl, this);
  • 19. _photoLayer.addChild(imgLoader); } } //-------------------------------------- // PRIVATE & PROTECTED INSTANCE METHODS //-------------------------------------- //UI private function createUI():void { // _headerBackground = new Sprite(); _headerBackground.graphics.beginFill(0x000000); _headerBackground.graphics.drawRect(0, 0, 430, 42); _headerBackground.alpha = 0.8; _guiLayer.addChild(_headerBackground); // _tf = createTextField(10, 10, 200, 20); _tf.wordWrap = true; _tf.type = TextFieldType.INPUT; _tf.text = quot;quot;; // _searchButton = new SimpleButton(); _searchButton.x = 214; _searchButton.y = 10;
  • 20. _searchButton.upState = makeRoundRect(0x666666, quot;searchquot;); _searchButton.overState = makeRoundRect(0xcc0000, quot;searchquot;); _searchButton.downState = makeRoundRect(0x3399cc, quot;searchquot;); _searchButton.hitTestState = _searchButton.upState; _searchButton.addEventListener(MouseEvent.CLICK, onSearchButtonClick); _guiLayer.addChild(_searchButton); // _resetButton = new SimpleButton(); _resetButton.x = 316; _resetButton.y = 10; _resetButton.upState = makeRoundRect(0x666666, quot;reset quot;); _resetButton.overState = makeRoundRect(0xcc0000, quot;reset quot;); _resetButton.downState = makeRoundRect(0x3399cc, quot;reset quot;); _resetButton.hitTestState = _resetButton.upState; _resetButton.addEventListener(MouseEvent.CLICK, onResetButtonClick); _guiLayer.addChild(_resetButton); } // private function createTextField(x:Number, y:Number, width:Number, height:Number):TextField { // var result:TextField = new TextField(); result.x = x; result.y = y;
  • 21. result.width = width; result.height = height; result.border = true; result.background = true; // var textFormat:TextFormat = new TextFormat(); textFormat.font = quot;Lucida Grandequot;; textFormat.color = 0x444444; textFormat.size = 12; result.defaultTextFormat = textFormat; _guiLayer.addChild(result); return result; } // private function makeRoundRect(color:uint, st:String):Sprite { // var s:Sprite = new Sprite(); s.graphics.beginFill(color); s.graphics.drawRoundRect(0, 0, 100, 21, 21); s.graphics.endFill(); // var t:TextField = new TextField();
  • 22. t.x = 0; t.y = 0; t.width = 100; t.autoSize = TextFieldAutoSize.CENTER; t.text = st; // var textFormat:TextFormat = new TextFormat(); textFormat.font = quot;Lucida Grandequot;; textFormat.color = 0xFFFFFF; textFormat.size = 12; t.setTextFormat(textFormat); s.addChild(t); return s; } } }