/** * Class: MyFlipPhotos * * 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 file and class name to MyFlipPhotos.fla / as and all references within the class * Changed the API key to mine ( not activated ?) and the NSID to mine. - that works * Added onRollOver, onRollOut to zoom the images. */ 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.petitpub.flickr.MyFlipPhotos { /** * 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; /** * Variable: xMax * Max horisontal value for left upper corner of a zoomed image **/ var xMax = 38; /** * Variable: yMax * Max vertical value for left upper corner of a zoomed image **/ var yMax = 76; /** * Variable: xTemp, yTemp * Temporary original x, y position values for images **/ var xTemp:Number; var yTemp:Number; /** * Function: MyFlipPhotos * Constructor **/ function MyFlipPhotos(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; // We have to set this for every mc to access the values from the event handlers mc.xMax = xMax; mc.yMax = yMax; var freeDepth=(_root.getNextHighestDepth()); // add the onPress to this movieclip to link to the relevant photo on flickr.com mc.onPress = function(){ getURL(this["photo"].photoPageUrl, "_blank"); }; // add the onRollOver and onRollOut event handlerz to zoom the image mc.onRollOver = function(){ xTemp=this._x; // Save the original position yTemp=this._y; this._x = Math.min(xTemp, xMax); this._y = Math.min(yTemp, yMax); // Swap this mc to first free depth this.swapDepths(freeDepth); this._xscale=this._yscale=100; } mc.onRollOut = function(){ this._x = xTemp; this._y = yTemp; this._xscale=this._yscale=49; } } } /** * Function: main * Entrypoint to the application. **/ public static function main():Void { var u:MyFlipPhotos = new MyFlipPhotos(_root); } /** * Function: toString **/ public function toString():String { return "[com.petitpub.flickr.MyFlipPhotos]"; } }