mobilePickPhoto and "last image" statement

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

mobilePickPhoto and "last image" statement

Post by Mag » Sun Dec 30, 2012 3:52 pm

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: mobilePickPhoto and "last image" statement

Post by jacque » Mon Dec 31, 2012 2:38 am

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: mobilePickPhoto and "last image" statement

Post by Mag » Tue Jan 01, 2013 11:19 pm

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:

Post Reply