Page 1 of 1

Image from URL doesn't display

Posted: Sun Mar 15, 2015 11:29 am
by andio
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

Re: Image from URL doesn't display

Posted: Sun Mar 15, 2015 11:57 am
by Dixie

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...

Re: Image from URL doesn't display

Posted: Sun Mar 15, 2015 12:10 pm
by jmburnod
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

Re: Image from URL doesn't display

Posted: Sun Mar 15, 2015 12:23 pm
by andio
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.

Re: Image from URL doesn't display

Posted: Sun Mar 15, 2015 12:27 pm
by andio
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

Re: Image from URL doesn't display

Posted: Sun Mar 15, 2015 12:49 pm
by jmburnod
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

Re: Image from URL doesn't display

Posted: Sun Mar 15, 2015 12:55 pm
by Dixie
What is your script for downloading the image and saving it to the temp folder ?

Re: Image from URL doesn't display

Posted: Sun Mar 15, 2015 4:02 pm
by Klaus
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

Re: Image from URL doesn't display

Posted: Mon Mar 16, 2015 9:03 am
by andio
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 ...