preload files from URL in web application
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
preload files from URL in web application
Hi!
I have been struggling with this issue for many days now, I hope someone has ANY clue that can help, please!
Here it's the issue: I am trying to deploy a web application that has a bunch of images from a URL. What's the most effective way to load them?
I thought that loading the URL when opening the stack and starting always from a card that has all the images in it, I could avoid having to hit the server when opening other cards later.
I set up a card that is not accesible with any button from the other cards, and that contains all the images I need to show. Each image object has the source path to a png file in that URL and they are all invisible.
The other cards show some specific images in each one of them, using the IDs of the images in that "hidden" card as icons for transparent buttons.
In the stack code I have:
on openstack
load URL "myserver's http"
go to card "hidden"
end openstack
and then in the "hidden" card I tell it to go to the main card on opencard.
It takes around 30 sec to load the stack and show the main card. Then, when I go to a card that has the same images as the one being currently displayed, it loads instantly, but if the images are different, it takes 5 secs.
Is there a way to load all the files in my URL (server) only once in the beginning and to have them ready/available for every card in the application?
Thank you so much!!!
I have been struggling with this issue for many days now, I hope someone has ANY clue that can help, please!
Here it's the issue: I am trying to deploy a web application that has a bunch of images from a URL. What's the most effective way to load them?
I thought that loading the URL when opening the stack and starting always from a card that has all the images in it, I could avoid having to hit the server when opening other cards later.
I set up a card that is not accesible with any button from the other cards, and that contains all the images I need to show. Each image object has the source path to a png file in that URL and they are all invisible.
The other cards show some specific images in each one of them, using the IDs of the images in that "hidden" card as icons for transparent buttons.
In the stack code I have:
on openstack
load URL "myserver's http"
go to card "hidden"
end openstack
and then in the "hidden" card I tell it to go to the main card on opencard.
It takes around 30 sec to load the stack and show the main card. Then, when I go to a card that has the same images as the one being currently displayed, it loads instantly, but if the images are different, it takes 5 secs.
Is there a way to load all the files in my URL (server) only once in the beginning and to have them ready/available for every card in the application?
Thank you so much!!!
Re: preload files from URL in web application
you should save the images onto the drive, or into memory. Because if you just have the filename set to an url, of course it only loads when actually shown. If you save them onto the drive, you can even keep them between starts of the app.
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: preload files from URL in web application
All the files have the "preload to memory" property checked.
If what you mean is that the images should be in my hard disk instead of in a URL, I think it's impossible because:
- They will be updated every 10 minutes, (they are graphs showing specific changing data)
- They need to be included in a website, so accesible from computers other than mine
Thanks for trying, though!
If what you mean is that the images should be in my hard disk instead of in a URL, I think it's impossible because:
- They will be updated every 10 minutes, (they are graphs showing specific changing data)
- They need to be included in a website, so accesible from computers other than mine
Thanks for trying, though!
Re: preload files from URL in web application
No what i mean is you first download the images, then set the images in the stack to the ones downloaded:
You can also do the download nonblocking, but then you have to make sure not to try to show the not yet downloaded image, which can be a big hassle.
Code: Select all
on startup --or whenever
set the downloadedImage of me to specialFolderPath("temporary") & "/image.jpg"
put url "http://url.of.an.image.jpg" into url ("binfile:" & the downloadedImage of me)
showImage
end startup
on showImage
set the fileName of image 1 to the downloadedImage of me
end showImage
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: preload files from URL in web application
That sounds like the way to go! Although, I don't manage to make it work 
I have been "self-learning" livecode pretty intensively for the last 6 months but never dealt with web deployments before...It has been also my first experience with coding...and it went pretty well so far but this is just driving me crazy!
I tried to put the code on openstack and when opening the web application, it crashes.
If I have 182 images that I need to download, do I need to write this code 182 times replacing "me" and "image 1" by the name of each image; and "/image.jpg" by the file for each image? Is there a way to make it generic?
If I leave "me" in the code, would it apply to every image in the application?
Thank you!

I have been "self-learning" livecode pretty intensively for the last 6 months but never dealt with web deployments before...It has been also my first experience with coding...and it went pretty well so far but this is just driving me crazy!
I tried to put the code on openstack and when opening the web application, it crashes.
If I have 182 images that I need to download, do I need to write this code 182 times replacing "me" and "image 1" by the name of each image; and "/image.jpg" by the file for each image? Is there a way to make it generic?
If I leave "me" in the code, would it apply to every image in the application?
Thank you!
Re: preload files from URL in web application
If by webapplication you mean the plugin, then you probably can't save stuff to the hard disk. Me always refers to the current object, that is executing the code, so it pertains to whatever is current I guess.
To repetitively do tasks that are the same, use a repeat loop
To repetitively do tasks that are the same, use a repeat loop
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: preload files from URL in web application
jaibon wrote:That sounds like the way to go! Although, I don't manage to make it work
I have been "self-learning" livecode pretty intensively for the last 6 months but never dealt with web deployments before...It has been also my first experience with coding...and it went pretty well so far but this is just driving me crazy!
I tried to put the code on openstack and when opening the web application, it crashes.
If I have 182 images that I need to download, do I need to write this code 182 times replacing "me" and "image 1" by the name of each image; and "/image.jpg" by the file for each image? Is there a way to make it generic?
If I leave "me" in the code, would it apply to every image in the application?
Thank you!
Chances are you can write a procedure/message handler or function that will let you pass in a file name and load it in dynamically based on some list of files.
You could generate the list and put it in a text file or something or a field and have your app use the array or text commands to pull the next file name.
Also, you can use references to me in an object orientated style. Check out some of the lessons.
Also, when you load a new image you can use the object reference, "last image" which will point to the latest new image to load onto the stack or card.