Page 1 of 1

mobilePickPhoto and "last image" statement

Posted: Sun Dec 30, 2012 3:52 pm
by Mag
Hi all, I'm using a button to show an image chosen by the user (imageButton). The first time you use the handler all goes fine, but he second time you use the handler, the icon of the button "imageButton" remains the one of the first image. Is there a kind LiveCode guru that tells me what I'm doing wrong?

Code: Select all

global photoSource

on mouseUp
   put "library" into photoSource
   pickPhoto
end mouseUp

on pickPhoto
   put the loc of graphic "shoppingPhoto" of cd "content" into theLoc
   put the height of graphic "shoppingPhoto" of cd "content" into theHeight
   put the width of graphic "shoppingPhoto" of cd "content" into theWidth
   
   mobilePickPhoto photoSource, theHeight, theWhidt -- photoSource is camera or library
   if the result is empty then -- no errors

      set the name of the last image to "myImageTempName" 
      set icon of button "imageButton" to "myImageTempName"
   end if
end pickPhoto

Re: mobilePickPhoto and "last image" statement

Posted: Mon Dec 31, 2012 2:38 am
by jacque
If every image is named "myImageTempName" and you haven't deleted the older ones, then the icon won't change because the engine will use the first image it finds with that name. You can either delete the original image, or name each new one differently.

Re: mobilePickPhoto and "last image" statement

Posted: Tue Jan 01, 2013 11:19 pm
by Mag
Hi Jacqueline, thank you so much for your post. Now I'm using a code similar this and it works!

Code: Select all

      if there is an image "myImage1" then
         put "myImage2" into imageName
      else
         put "myImage1" into imageName
      end if
      
      set the name of the templateimage to imageName
      set the loc of the templateimage to theLoc
      mobilePickPhoto photoSource, theHeight, theWhidt
      if the result = "" then 
         if the last char of imageName is "1" then -- delete old image
            delete image "myImage2"
         else
            delete image "myImage1"
         end if
     end if
Now I'm studying how to save the image on the device and open it when open stack again... :oops: