Image from URL doesn't display

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
andio
Posts: 7
Joined: Sun Mar 15, 2015 11:16 am

Image from URL doesn't display

Post by andio » Sun Mar 15, 2015 11:29 am

I'm trying to load an image from an URL at runtime and display the cached image.
I tried different variants but none of them worked.

Downloading the image itself actually did work. The image is in the temporary folder.

The problem is that the image is not displayed in the image object.

What is the correct way to have the image object display a certain image?

Code: Select all

on startup
   loadImage
end startup

on loadImage
   set the downloadedImage of me to specialFolderPath("temporary") & "/image.jpg"
   put url "http url/image.jpg" into url ("binfile:" & the downloadedImage of me)
   -- try 1:
   set the fileName of image "Image" to url ("binfile:" & the downloadedImage of me)
   -- try 2:
   set the fileName of image "Image" to the downloadedImage of me
   -- try 3:
   set the fileName of image "Image" to url "http url/image.jpg"
end loadImage

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Image from URL doesn't display

Post by Dixie » Sun Mar 15, 2015 11:57 am

Code: Select all

set the filename of image 1 to specialFolderPath("temporary") & "/image.jpg"
This should work..:-) assuming that the image exists in the 'temporary' folder...

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Image from URL doesn't display

Post by jmburnod » Sun Mar 15, 2015 12:10 pm

Hi andio,

Code: Select all

   put "http://www.alternatic.ch/jmb/devrev/marginrectInside.png" into turl
   set the filename of img 1 to tUrl
works for me
Best regards
Jean-Marc
https://alternatic.ch

andio
Posts: 7
Joined: Sun Mar 15, 2015 11:16 am

Re: Image from URL doesn't display

Post by andio » Sun Mar 15, 2015 12:23 pm

Something wrong with my stack? Both versions don't work here.

The file is in the temporary folder and if i choose that file in the Source-field in the inspector, the image is correctly shown in the stack.

But setting from within the code seems to do not work, nothing happends, the image object stays empty.

andio
Posts: 7
Joined: Sun Mar 15, 2015 11:16 am

Re: Image from URL doesn't display

Post by andio » Sun Mar 15, 2015 12:27 pm

Even this doesn't work. The image object is empty.
I just dropped an image object from the tools on the left onto the stack. Isn't that correct?
jmburnod wrote:Hi andio,

Code: Select all

   put "why cant i post urls this is annoying" into turl
   set the filename of img 1 to tUrl
works for me
Best regards
Jean-Marc

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Image from URL doesn't display

Post by jmburnod » Sun Mar 15, 2015 12:49 pm

When I've written this :shock:
put "why cant i post urls this is annoying" into turl
set the filename of img 1 to tUrl
https://alternatic.ch

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Image from URL doesn't display

Post by Dixie » Sun Mar 15, 2015 12:55 pm

What is your script for downloading the image and saving it to the temp folder ?

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Image from URL doesn't display

Post by Klaus » Sun Mar 15, 2015 4:02 pm

Hi andio,

1. welcome to the forum! :D

2. You need to have at least 10 postings before you can post URLs and attachments!

3. You should check THE RESULT after your action, that may give you a hint about what goes wrong.

Code: Select all

on loadImage
   set the downloadedImage of me to specialFolderPath("temporary") & "/image.jpg"
   put url "http url/image.jpg" into url ("binfile:" & the downloadedImage of me)

   ## THE RESULT = EMPTY on success!
   if the result <> EMPTY then
      answer "Problem:" && the result
   end if
...
Best

Klaus

andio
Posts: 7
Joined: Sun Mar 15, 2015 11:16 am

Re: Image from URL doesn't display

Post by andio » Mon Mar 16, 2015 9:03 am

Hi Klaus

i already did that, the result() was empty.

I started a new main stack and tried it again, now it works. I tried to find out the difference between the both, but there seems to be now difference. Both build for ios standalone, both have the same dimensions and the same buttons, just 50 lines of codes but there must be some difference. Maybe a bug in 7.0.4 ...

Post Reply