A problem occured while loading the plugin: krl_flickr_photoset -> : Assigning the return value of new by reference is deprecated on line 18
kelvinluck.com: FlashrSimpleSearch
Get Firefox! creative commons



For the latest up to date information about Flashr please check out the new Flashr microsite

Update: This example will no longer work as-is – you will need to update your Flashr files as described here.

Somebody on the Flashr mailing list was having difficulties getting to grips with Flashr. Since a picture is worth a thousand words and I needed to do some examples of using Flashr 0.5 anyway, I put this very simple example together…

Basically all it does is connects to the Flickr API and does a search for a tag using flickr.photos.search. It then calls flickr.photos.getInfo on each of the returned photos to get more detailed information (like authors name, description and tags used). Once it has got all this information it simply traces it to the output window in Flash.

All of this is made much easier by a feature in the as yet not officially released Flashr 0.5. Now when you make multiple requests to the Flickr API the requests are added to a queue and each one executes in turn. This makes writing applications that rely on multiple API requests (such as this one) much simpler.

You can download all the files for this example from here. This includes the latest version of Flashr 0.5 (see the trac timeline for recent changes). The specific file you are interested in is com.kelvinluck.flashr.example.FlashrSimpleSearch.as.

Here is the entire class which powers this little “application”.

import com.kelvinluck.util.LogWrapper;
import com.kelvinluck.flashr.core.FlashrResponse;
import com.dynamicflash.utils.Delegate;
import com.kelvinluck.flashr.core.ResultsSet;
import com.kelvinluck.flashr.core.Photo;
import com.kelvinluck.flashr.core.Flashr;
* Class: FlashrSimpleSearch
* Very simple example showing how to search for a tag using Flashr 0.5 and then
* get more detailed information about each matching photo.
* Currently just traces the relvant information out.
* Author:
* Kelvin Luck

class com.kelvinluck.flashr.example.FlashrSimpleSearch extends MovieClip
        public static var SEARCH_TAG:String = "snow";
        public static var NUM_RESULTS:Number = 10;
        private var _flashr:Flashr;
        private var _flashrResponse:FlashrResponse;
        private var _numResults:Number;
        private var _photos:Array;
        * Function: FlashrSimpleSearch
        * Constructor

        function FlashrSimpleSearch()
                // uncomment the following lines if you want to see the internals of what is happening with Flashr.
                _photos = [];
                _flashr = Flashr.getFlashr();
                _flashr.apiKey = "b40e05adf210ad4c4cc4da00f99f4184";
                _flashr.cacheQueries = true;
                _flashrResponse = new FlashrResponse();
                _flashrResponse.onPhotosSearch = Delegate.create(this, onPhotosSearch);
                _flashrResponse.onPhotosGetInfo = Delegate.create(this, onPhotosGetInfo);
                trace("Searching for " + NUM_RESULTS + " photos matching tag '" + SEARCH_TAG + "'");
                _flashr.photosSearch({tags:SEARCH_TAG, per_page:NUM_RESULTS});
        function onPhotosSearch(rs:ResultsSet)
                _numResults = rs.photos.length;
                trace("Loaded data for " + _numResults + " photos out of " + rs.total + " matching tag, requesting more details about each photo");
                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("Loaded detailed data for photo '" + photo.id + "'");
                if (_photos.length == _numResults) {
        function onAllPhotosLoaded()
                trace("*************ALL PHOTO INFO LOADED*************");
                trace(" ");
                for (var i:Number=0; i<_photos.length; i++) {
                        var thisPhoto:Photo = _photos[i];
                        trace("Photo " + thisPhoto.id + " :");
                        trace("  Title: " + thisPhoto.title);
                        trace("  Description: " + thisPhoto.description);
                        trace("  Taken: " + thisPhoto.dateTaken);
                        trace("  Author: " + thisPhoto.owner.username);
                        trace("  Author ID: " + thisPhoto.owner.nsid);
                        trace("  Thumbnail: " + thisPhoto.thumbnailUrl);
                        trace("  Photo page URL: " + thisPhoto.photoPageUrl);
                        trace("  Tags: " + thisPhoto.getTagsAsStrings());
                        trace(" ");
        * Function: toString

        public function toString():String
                return "[com.kelvinluck.flashr.example.FlashrSimpleSearch]";

I hope this is useful to someone, please leave any feedback as a comment below or on the Flashr mailing list.

  1. Hi,

    simple problem… I can´t open your FlashrSimpleSearch.fla would you please send it to me? Thanks!

    Andreas    Oct 15, 16:23    #
  2. Hi,

    What version of Flash are you trying to open it in? I think it was a Flash 8 fla file. I have just resaved it as a Flash MX2004 file and reuploaded it so please download it again and see if you can open it now,


    Kelvin Luck    Oct 15, 16:29    #
  3. Thanks! now it works on 2004…

    Andreas    Oct 16, 11:43    #
  4. Hi,

    Is Flashr 0.5 officially released yet? It seems that only this example is written in version 0.5? I would like to know which version to use at this time point. Thanks a lot:)

    — Gloria    Dec 11, 14:46    #
  5. Yes – 0.5 is more or less officially released. You can get it here – I’ve just been too busy to get the microsite for it ready but that should be coming by the start of the new year,


    Kelvin :)

    Kelvin Luck    Dec 11, 15:04    #
  6. Hi,

    Thanks for the prompt reply though I am still a little bit confused:) From the download section in this sample, you mentioned you include the latest version of Flashr 0.5. But you have another newest 0.5 version in http://flashr.kelvinluck.com/assets/0.5/ ? Are these two packages the same one? If not, I guess http://flashr.kelvinluck.com/assets/0.5/ is the very newest one, then could this example work with this version? And, I saw in the FlashrSimpleSearch.fla, there is no code inside, and the real code FlashrSimpleSearch.as is in the \FlashrSimpleSearch\src\com\kelvinluck\flashr\example. How do you make this work? I mean 1) how you include FlashrSimpleSearch.as into the .fla file, 2) I thought the files under \com\... should be at the same directory with the real source code (I am not sure the real source code is the .fla or .as in this case)

    Thanks again!

    — Gloria    Dec 12, 15:33    #
  7. Oh, Excuse me…
    another questions…

    I am aware that you made a fix (https://mirror1.cvsdude.com/trac/osflash/flashr/changeset/54). But while I look into the previous page, I found there are two files-Flickr.as and Flashr.as needed to be changed, but I can only find Flashr.as encompassed in this FlashrSimpleSearch example. 2) While I try to excute FlashrSimpleSearch.swf, it will appear a security warning window, and I already went to the http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04a.html (Global security settings for content creators) to trust file in the location (e.g., C:\flash\FlashrSimpleSearch\deploy and C:\flash\FlashrSimpleSearch\deploy\FlashrSimpleSearch.swf). I do not know which previous one location is correct, so I add both of them, but while I try to re-excute the .swf file, the warning still presents.

    — Gloria    Dec 12, 15:53    #
  8. Hi Gloria,

    This sample included the latest version of Flashr at the time it was published. The link I gave you in my last comment is a slightly newer version. The example should work fine with the newer version.

    The code in FlashrSimpleSearch is a class which is associated with a symbol in the library. This is how code is included in AS2 – I recommend searching around for an intro to AS2 or reading reading Colin Moock’s Essential ActionScript 2

    The two files that were fixed were the 0.4 and the 0.5 version. You will only need to change Flashr.as since that corresponds to the 0.5 version.

    You should run FlashrSimpleSearch.swf from within the Flash IDE (Ctrl-enter) or from a webserver. The issue you describe is due to the “local content can’t access internet content” flash security restriction, not the crossdomain.xml file and the endpoint for the flickr API.

    Hope all that helps! In future you may find it more useful to ask questions about Flashr on the Flashr mailing list

    Kelvin Luck    Dec 12, 22:35    #
  9. Hi,

    I have fixed the Flashr.as and use “Ctrl+Enter” to test the FlashrSimpleSearch.fla. But the result window is a blank although I do see the tracing message of photo details in the output window. Then, I saw the ..\deploy\FlashrSimpleSearch.swf has been updated, so I copied this file to my root directory of webserver (C:\Inetpub\wwwroot), and I opened the web browser to test http://myIP/FlashrSimpleSearch.swf or http://myIP/FlashrSimpleSearch.html (I changed the publish settings in Flash to publish this html as well) and I can see the message “transfering data from api.flickr.com…”, but there is still no photo showing up. Any ideas? Thanks a lot!

    — Gloria    Dec 14, 12:08    #