views:

24

answers:

0

Hi all,

I'm trying to work with the as3flickrlib, but I seem to constantly be running into trouble at every corner. Among other things that I want to do, I am trying to build a search function that only searches the photos returned from my groups.pools.getPhotos call. All the photos are being fed into an Array, so I'm wondering if I could just search said array based on the data. It doesn't look like there is a built in groups.pools.search method or anything like that in the Flickr API, so I am wondering if there's an easy way to search through the array, and if I can access each photo's details within it ( ie. search by user id, description, tags, etc ).

Here's some code:

private function showPhotos( e : FlickrResultEvent ):void 
    {

        if ( e.success ) trace( "successfully connected to " + Constants.GROUP_ID + "'s photos!" );

        _pArray = e.data.photos.photos as Array;
        trace( _pArray.length );

        addChild( thumbHolder );

        var xPos: int = 0;
        var yPos: int = 0;

        //loop through all the photos, creating an instance of the Photo object from each node
        //in the array. we can construct the URL of each image by extracting the data within the Photo obj
        for ( var i: int = 0; i < _pArray.length; i ++ ) 
        {       
            var p: Photo = _pArray[i];

            var src: String = "http://farm" + p.farm + ".static.flickr.com/" + p.server + "/" + p.id + "_" + p.secret;

            trace( p.id, p.title )

            var thumb: FlickrImage = new FlickrImage( Constants.SQUARE, src, p.title );

            xPos += 106;

            thumb.x = xPos;
            thumb.y = yPos;

            if( xPos > 800 )
            {
                xPos = 0;
                yPos += 106;
            }

            trace( thumb.x, thumb.y );


            //t.x = 1 + ( i % 12 ) * 76; 
            //t.y = 1 + ( Math.floor( i / 12 ) ) * 76;
            thumb.addEventListener( MouseEvent.CLICK, launchPhoto );
            thumbHolder.addChild( thumb );
        }

FlickrImage is a custom class I created that just handles the size, source, and title of the image being called in. It does not call anything from the Flickr API. And thumbHolder is a Sprite that holds the thumbnails.

Does anyone have any idea how I can go about searching through these photos?

Thanks in advance.