|
Email lists >
>
Re: [Flashr] Hello World Example >
Re: [Flashr] Hello World Example
Re: [Flashr] Hello World Example
This post if a part of this thread
|
2008-02-17 05:37:48 |
|
|
Re: Hello World Example
|
Great - thanks for the example,
Cheers,
Kelvin
Kevin Cannon wrote:
> Hi there,
>
> Just wanted to post up a very simple hello world
example for Flashr.
> I've been playing around with it all morning and I'm
not very familiar
> with how more advanced developers package things up. It
actually took
> me quite awhile to realise the main code was in the com
directory. I
> just assumed that was the library of classes, so dumped
in into my
> AS2Classes directory -- oops.
>
> Anyway, to help me learn I threw out all the stuff, and
wanted the
> most basic example possible to start from. Here's what
I came up with,
> and it's a good starting point for me. Posting it here,
in the hope
> it'd be useful to others.
>
> Thanks,
>
> - Kevin
>
> import com.kelvinluck.flashr.core.*;
> import com.dynamicflash.utils.Delegate;
>
> // Settings
> var NUM_RESULTS:Number = 2;
>
> // Variables
> var _numResults:Number;
> var _photos:Array;
>
> // Instances
> var _flashr:Flashr;
> var _flashrResponse:FlashrResponse;
>
> // Setup
> _flashr = Flashr.getFlashr();
> _flashr.apiKey =
"b40e05adf210ad4c4cc4da00f99f4184";
> _flashr.cacheQueries = true;
>
> _flashrResponse = new FlashrResponse();
> _flashrResponse.onPhotosSearch = Delegate.create(this,
onPhotosSearch);
> _flashrResponse.onPhotosGetInfo = Delegate.create(this,
onPhotosGetInfo);
>
>
> // Main Functions
> function doSearch(tags:String)
> {
> trace("Searching for " + NUM_RESULTS +
" photos matching tag '" +
> tags + "'");
> _photos = [];
> _flashr.photosSearch({tags:tags,
per_page:NUM_RESULTS});
> }
>
>
> function onPhotosSearch(rs:ResultsSet)
> {
> _numResults = rs.photos.length;
> trace("FLASHR->onPhotosGetInfo: " +
_numResults);
>
> for (var i:Number=0; i<_numResults; i++) {
> var thisPhoto:Photo = rs.photos[i];
> _flashr.photosGetInfo(thisPhoto.id,
thisPhoto.secret);
> }
> }
>
> function onPhotosGetInfo(photo:Photo)
> {
> trace("FLASHR->onPhotosGetInfo");
>
> _photos.push(photo);
> if (_photos.length == _numResults) {
> onAllPhotosLoaded();
> }
> }
>
> function onAllPhotosLoaded() {
>
> trace("FLASHR->onAllPhotosLoaded");
>
> for (var i:Number=0; i<_photos.length; i++) {
> var thisPhoto:Photo = _photos[i];
> trace("Photo " + thisPhoto.id + "
:");
> trace(" Title: " + thisPhoto.title);
> }
>
> }
>
>
> doSearch("fish");
>
> _______________________________________________
> Flashr mailing list
> Flashr osflash.org
> http://osflash.org/mailman/listinfo/flashr_osflash.org
_______________________________________________
Flashr mailing list
Flashr osflash.org
http://osflash.org/mailman/listinfo/flashr_osflash.org
|
|
|
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|