We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Problem with flickr
Page Index Toggle Pages: 1
Problem with flickr (Read 531 times)
Problem with flickr
Oct 1st, 2009, 3:02pm
 
So I have flicker displaying images, and a text box for users to enter what they think the pictures are of.
I have a list of Strings consisting of generic terms like "sky", "ocean".
The issue is that after the user guesses the correct term, say its sky, processing continues displaying images with sky.
It also begins showing the ocean images, so you get a mix of sky and ocean pictures and it makes it very difficult to keep on playing the game.

When a search is made through flickr, it returns an arraylist of image results.
I have tried doing flickrImages.clear() after the correct input is made, but that doesnt seem to have any affect what so ever.

Ill post part of the code(a lot of which was provided for me, which may be why I cant figure it out) but just ask if you need to see all of it.

Any other tips for a mediocre programmer would be very appreciated.

Code:
// these lists contain the data that is used in drawing
// in order to draw based on content that you load, it must go in some sort of intermediary storage.
java.util.List flickrImages = Collections.synchronizedList(new ArrayList()); // contents: PImage

int MAX_FLICKR_IMAGES = 6;

// *** FLICKR ***
void onFlickrPhotos(FlickrPhotoShortResult[] results) {

 while (true) {
   // flickr returns 100 results.
   // we go through the same 100 results indefinitely.
   // if we load all 100, we'll get a scary OutOfMemoryError

   for(int i=0;i<results.length;i++) {
     PImage flickrImage = loadImage(results[i].getImageUrl());
     flickrImages.add(flickrImage);
     
     if(flickrImages.size() > MAX_FLICKR_IMAGES)
       flickrImages.remove(0); // pop the bottom one.
   }
 }
 
}
...
//this "texts" method gets called when the user hits enter after typing in the text field.
public void texts(String theText) {
 //println("a textfield event. "+theText);
 if(theText.equals(searchTerm[num])){
   println("WIN");
   if(num >= 2){
     num = 0;}
   else{    
     num += 1;}
   
   flickrImages.clear();  //why doesnt this do anything?
   flickrSearch();
 }
 else{
   println("LOSE");
 }
}
Re: Problem with flickr
Reply #1 - Oct 2nd, 2009, 1:47am
 
Quote:
flickrImages.clear();  //why doesnt this do anything?

Add a println(flickImages); after this line, to see if it works or not.
Page Index Toggle Pages: 1