View Full Version : preloading panoramas
andres009
04-17-2008, 11:23 PM
Hello fellows,
I'm trying to preload a set of panoramas from a Flash application. Is there any function in the plug in that I can use?
Other option...
Thank you for any help.
Scott Witte
04-20-2008, 05:48 PM
Zephyr has his Image Cache Plug-In (http://flashpanos.com/plugins/zephyr/image-cache-plug) at Flashpanos.com (http://flashpanos.com/)
There is some question or confusion about whether or how well it actually works. Perhaps Zephyr, if he sees this thread, can clear that up.
HansNyberg
04-21-2008, 11:18 AM
AS long as you use images (cubefaces) you can just use a standard javascript preloading script in your html file.
Works perfect in all browsers. Safari will however not load more than around 15-18 mb in all.
Hans
djsegler
04-25-2008, 03:58 AM
What's the javascript/html syntax for loading the images so it's compatible with the pano or pano0 swf files?
This is what I've used before:
<SCRIPT LANGUAGE="JavaScript">
<!-- hide from none JavaScript Browsers
Image1= new Image(700,500)
Image1.src = "images/image_0.jpg"
Image2 = new Image(700,500)
Image2.src = "images/image_1.jpg"
// End Hiding -->
</SCRIPT>
Does this still apply here? How should the images be named or referrenced? This method doesn't seem to be having any effect so far.
cheathamlane
04-25-2008, 06:17 AM
Hmm...
Maybe try putting that in an actual function call, and calling it from the onload of your HTML doc?
I don't think this is an FPP issue...
phberlin
04-25-2008, 11:45 AM
@djsegler
Maybe you could, like cheathamlane suggested, try using something like this:
<script language="JavaScript">
<!-- hide from non-JavaScript-browsers
function PreloadImages()
{
var myImage1 = new Image();
myImage1.src = 'images/image1.jpg';
var myImage2 = new Image();
myImage2.src = 'images/image2.jpg';
}
// End Hiding -->
</script>
<body onload="PreloadImages()">
Haven't tried this yet, but maybe it works. Please let us know if it's of any use.
Regards, Ph.
djsegler
04-25-2008, 11:49 AM
I'll try this - but I still have a question about how to name the images.
What naming convention should I use in either the HTML or FPP so that things match?
I'm using cube faces that are named as name_# along with pano0.swf -
Do I use it as usual and just use the HTML with whatever *.src names I choose to just get them loaded?
phberlin
04-25-2008, 01:09 PM
Please note that I've changed something in the code below, so if you copy and pasted it, just do it again :-)
As to your naming question: Why don't you just take the specific filenames (including the path) that are to be preloaded? So, if you have "cubeface_0.jpg", "cubeface_1.jpg" and so on, just take these..?! But maybe I don't get your question....
djsegler
04-25-2008, 01:22 PM
Let me be more specific...
As an example, assuming I'm using the format of cubeface_0.jpg for my panos today...
The HTML would use the statements like this:
var cubeface_0 = newimage ();
cubeface_0.src = 'cubeface_0.jpg';
var cubeface_1 = newimage ();
cubeface_1.src = 'cubeface_1.jpg';
etc....
Is this correct?
Scott Witte
04-25-2008, 06:56 PM
I almost hesitate to bring this up since I can't find the source code just now, plus my near total lack of javascript knowledge will be all too evident but...
I saw a nice trick allowing you to precache images with a javascript loop that would go something like this:
for n=0; n<=5; n++ {
var cubeface = newimage();
cubeface.scr = "panoName_" + n + ".jpg";
}
Of course, instead of "panoName_" you would have something like "images/entrance_".
Even cooler, panoName could itself be a variable constructed from a list of panonames, so you just input the list and all the cubefaces for all the panos are preloaded. Someone who actualy knows javascript could probably whip that code into order in no time. ;)
But what I really want is a way to call this dynamically from FPP. Lets say you have a tour with 10 nodes. The panos you most want preloaded will be the ones most likely visited from the pano currently displayed. So lets say you create the script described above and call it panoPreload. When you do a loadPano in FPP you could include something like:
onTransitionEnd = javascript: panoPreload(images/reception, images/auditorium);
Would that work? Can FPP's javascript command call a named script in the underlying HTML and pass variables to it?
cheathamlane
04-25-2008, 07:25 PM
Scott:
http://flashpanoramas.com/forum/showthread.php?t=1083&highlight=javascript
Have you tried it? I haven't, but following the logic from this post and the above linked thread (regarding your window.close issue), it seems to me it _should_ work.
You could end up with something like:
onClick="javascript:panoPreload('images/reception', 'images/auditorium');"
Scott Witte
04-26-2008, 07:36 PM
Patrick,
Something was wrong with your link, but for anyone interested the thread referred to is this: close browsr from a hotspot? (http://flashpanoramas.com/forum/showthread.php?t=1083&highlight=javascript)
Anyway, while it is often against my nature ;) I decided to RTFM and Denis says about the javascript command: "You can use it to open new popup windows (a way to avoid popup blockers) and to run any external Javascript functions:"
So, it certainly should work... if only I knew enough javascript to write the function, in particular how to pass a string of variables to it and process those variables in sequence. Learning that won't happen very soon, I'm afraid, as I have more pressing issues. :(
But for anyone who knows javascript (and you know who you are), everything is in place. I would love to see someone do this.
cheathamlane
04-26-2008, 11:07 PM
So, it certainly should work... if only I knew enough javascript to write the function, in particular how to pass a string of variables to it and process those variables in sequence. Learning that won't happen very soon, I'm afraid, as I have more pressing issues. :(
:p
Scott (Mr. Humble), you can write AS can't you? ;) All the pieces are right here in this thread...
See a working example of calling a JS from your FPP onClick at:
http://www.flashpanos.com/flashpanos_files/examples/patrick/dropdownv2/dropdown-allParams-test2.html
View HTML source for the JavaScript function & XML source for the onClick. The onClick of the button should show a JavaScript Alert box, with "Hello" and the panoNames that were passed to it.
--
I leave if/else blocks, for loops and switching to you...
HTH
Scott Witte
04-27-2008, 01:09 AM
:D :D
:The onClick of the button should show a JavaScript Alert box, with "Hello" and the panoNames that were passed to it.
--
I leave if/else blocks, for loops and switching to you...
Too funny! You easily answered one of my questions (passing paramaters). Now, how where you thinking I would tackle the loop in the js function to construct a sequence of "panoname" variables and debug the image preloading loop so it actually worked? A functioning example would be appreciated
:D :D
Seriously, it can obviously be done and maybe without that much difficulty. Right now I have to figure out how to sync two audio files and keep them in sync. That is proving a real challenge, although reading the AS3 docs you wouldn't think so. But that is a little OT for this thread.
cheathamlane
04-27-2008, 02:26 AM
Too funny! You easily answered one of my questions (passing paramaters). Now, how where you thinking I would tackle the loop in the js function to construct a sequence of "panoname" variables and debug the image preloading loop so it actually worked? A functioning example would be appreciated
--
Seriously, it can obviously be done and maybe without that much difficulty. Right now I have to figure out how to sync two audio files and keep them in sync. That is proving a real challenge, although reading the AS3 docs you wouldn't think so. But that is a little OT for this thread.
I had a really nice long answer for this post, but Safari crashed on me twice... ARGH!
Has anyone else had issues with Safari and the Flash Player debug version 9r124?
--
Example code below -- could be much neater, but here you go for free and on the quick. ;). This is based on an example from my dusty old DreamWeaver MX 2004 Javascript Reference; Macromedia's example Javascripts abound on the internet in many permutations. Here's mine:
//JAVASCRIPT:
function simplePreload(){
var args = simplePreload.arguments;
var panoSourceName;
document.imageArray = new Array();
for(var i=0; i<args.length; i++) {
for(var z=0; z<6; z++) {
document.imageArray.push(new Image);
if (z==0) {
panoSourceName = args[i] + "_b.jpg";
}
if (z==1) {
panoSourceName = args[i] + "_d.jpg";
}
if (z== 2) {
panoSourceName = args[i] + "_f.jpg";
}
if (z== 3) {
panoSourceName = args[i] + "_l.jpg";
}
if (z== 4) {
panoSourceName = args[i] + "_r.jpg";
}
if (z== 5) {
panoSourceName = args[i] + "_u.jpg";
}
//BELOW LINE FOR PRODUCTION:
//document.imageArray[imageArray.length-1].src = panoSourceName;
//BELOW LINE FOR TESTING:
alert(panoSourceName);
}
}
}
//XML
<spot
id="myspot"
url="myspot.png"
onClick="javascript:simplePreload('images/reception', 'images/auditorium');"
/>
The link in my post above uses this script.
HTH
Scott Witte
04-27-2008, 03:42 AM
Looking Good, Patrick! Looking forward to experimenting with this when I have more time. Guess I'm obligated now, thanks to you...
Once again you prove yourself one of the great treasures of this forum. They just don't pay you enough!
cheathamlane
04-27-2008, 03:56 AM
Looking Good, Patrick! Looking forward to experimenting with this when I have more time. Guess I'm obligated now, thanks to you...
Ha, cool -- get to it!
I haven't _really_ tested it -- but it should work. Even with all the above code & posts, though, it seems like a little bit of work. Something like Zephyr's image cache plugin could save a few keystrokes, and keep everything FPP-centric (i.e., out of the HTML).
Once again you prove yourself one of the great treasures of this forum. They just don't pay you enough!
;) Thanks... Now go buy one of my plugins, will you? :rolleyes:
I would be curious, though, about the sound syncing... I have yet to 1) need to deal with it and 2) get my head around AS3 sound handling. :P
Cheers
Scott Witte
04-27-2008, 04:28 AM
Even with all the above code & posts, though, it seems like a little bit of work. Something like Zephyr's image cache plugin could save a few keystrokes, and keep everything FPP-centric (i.e., out of the HTML).
...As I suggested earlier. (Or was it just in several other threads?) Actually I still haven't seen Zephyr explain the bugs some people have encountered and really wish he would. While everything we've discussed here may work great for cubefaces it doesn't help at all with any other media types. Zephyr's plugin could. And I would really rather use that than build my own. I will have to follow one path or the other before long.
Zephyr, where art thou?
BTW, I had my wallet out ready to buy Extensible Tooltips (http://flashpanos.com/plugins/zephyr/extensible-tooltips) but then it turned out to be FREE! What's a capitalist to do? Not that I'm complaining.
cheathamlane
04-27-2008, 05:18 AM
BTW, I had my wallet out ready to buy Extensible Tooltips (http://flashpanos.com/plugins/zephyr/extensible-tooltips) but then it turned out to be FREE! What's a capitalist to do? Not that I'm complaining.
:p
Heh, fair enough! You try to be a good consumer, and get foiled at every turn.
Well, you can always buy one of my prints... :twisted:
http://www.cheathamlane.net/prints/
Cheers
vBulletin® v3.7.1, Copyright ©2000-2010, Jelsoft Enterprises Ltd.