/** * Class: UserRecentPhotos * * Very simple class that connects to flickr.com using the Flashr library and * get's the last 16 photos for a given user and loads them into position on a * nice grid. * * Compile using MTASC and the provided ANT file (build.xml). You will need to * edit the classpath in the ANT file for this to work. * * Or compile using MTASC and the following commandline (assuming that MTASC is in * your PATH and you have edited the classpath): * * (start code) * mtasc.exe -header 305:305:25:000000 -main -swf ../deploy/UserRecentPhotos.swf -cp "C:\Documents and Settings\kelvinl\Local Settings\Application Data\Macromedia\Flash MX 2004\en\Configuration\Classes" com\kelvinluck\flickr\example\UserRecentPhotos * (end) * * Or by executing the provided .bat file (again assuming that MTASC is in your PATH * and you have edited the classpath). * * Or compile using the Flash IDE by simply loading the provided .fla file and exporting. * * Author: * Kelvin Luck * * See Also: * * * * Changes by Petit: Changed flie and calss name to MyRecentPhotos.fla / as and all references within the class * Changed the API key to mine ( not activated ?) and the NSID to mine. - that works */ import com.kelvinluck.flickr.Flickr; import com.kelvinluck.flickr.FlickrResponseListener; import com.kelvinluck.flickr.Person; import com.kelvinluck.flickr.Photo; import com.kelvinluck.util.LogWrapper; import com.dynamicflash.utils.Delegate; class com.kelvinluck.flickr.example.MyRecentPhotos { /** * Variable: apiKey * Your API Key. * * See Also: * **/ var apiKey:String = "9ee44835b39e2f49deb3c82944ce776c"; //original key : 92502cc96511a84c1cfdbf990b71e8c1 /** * Variable: userNsid * The NSID of the user whose photos you want to get **/ var userNsid:String = "94579227@N00"; // original user: 51035610516@N01 /** * Variable: _target * The MovieClip to attach the photo thumbnails to **/ var _target:MovieClip; /** * Function: MyRecentPhotos * Constructor **/ function MyRecentPhotos(target:MovieClip) // target is _root here { Stage.scaleMode = "noScale"; // initalise logging to Flash's output window LogWrapper.getInstance().init(); LogWrapper.getInstance().addTracePublisher(); _target= target; var _flickr:Flickr = Flickr.getFlickr(); _flickr.apiKey = apiKey; var _flickrResponseListener:FlickrResponseListener = new FlickrResponseListener(); _flickrResponseListener.setSuppressOutput(true); _flickrResponseListener.onPeopleGetPublicPhotos = Delegate.create(this, onPeopleGetPublicPhotos); _flickr.peopleGetPublicPhotos(userNsid, null, 12,1); // changed from (,,16,) } /** * Function: onPeopleGetPublicPhotos * Called when the _flickrResponseListener hears a response to flikr.people.getPublicPhotos * * Parameters: * p - The whose s you just got. **/ function onPeopleGetPublicPhotos(p:Person):Void { var photosArray:Array = p.getPhotos(); var userNsid:String = p.nsid; for (var i:Number=0; i i%3 mc._y = Math.floor(i/3) * 38; // changed i/4 -> i/3 -> matrix 3 wide 4 high and distance // create a nested movieclip so that our onPress isn't overwritten by the jpg as it loads mc.createEmptyMovieClip("jpgHolder", 1); // and load the jpeg into it mc.jpgHolder.loadMovie(thisPhoto.thumbnailUrl); mc._xscale=mc._yscale=49; // trying to scale but ought to resample mc.photo = thisPhoto; // add the onPress to this movieclip to link to the relevant photo on flickr.com mc.onPress = function() { getURL(this["photo"].photoPageUrl, "_blank"); }; } } /** * Function: main * Entrypoint to the application. **/ public static function main():Void { var u:MyRecentPhotos = new MyRecentPhotos(_root); } /** * Function: toString **/ public function toString():String { return "[com.kelvinluck.flickr.example.MyRecentPhotos]"; } }