Topic: Load Galleries placed in different folders

Hello,

In the exemple of flash embedded FLA,
galleries are placed in the same folderwith the swf file, the folder "images" etc..

To use sv manager, i need to place each gallery in different folder

When i compile my FLA, it works great with:
loadGallery("/presse/gallery.xml");

But when i put all the files online, it doesn't work.
How to indicate the path of the differents galleries.
I need 10 galleries on my website

This is the AS code i put.
My simpleviewer.swf is on the root with my swf website
Do i put this code just one time or for each galleries?

import flash.display.*;
import flash.net.URLRequest; 

stage.align = StageAlign.TOP_LEFT;        

var svAPI:Object; //svAPI is the object to call API methods on
var swfLoaded:Boolean = false;
var galleryURL:String; //used when switching between galleries
var svLoader:Loader = new Loader(); //loader to load SimpleViewer swf into

presseloader.addChild(svLoader);

svLoader.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit);

loadGallery("/presse/gallery.xml");
function loadGallery(url:String){
    
    galleryURL = url;
    
    if (svAPI != null ) svAPI.dispose();
    svAPI = null;
    if (swfLoaded) svLoader.unload();

    var urlReq:URLRequest = new URLRequest("simpleviewer.swf");
    svLoader.load(urlReq);
    swfLoaded = true;
}
function onViewerInit(e:Event):void{
    trace("onViewerInit");
    
    Object(svLoader.content).addEventListener("svComplete", onGalleryLoaded); 
    
    trace("setViewerFlashVars");
    var options:Object = Object(svLoader.content).embedOptions;
     set gallery.xml url based on current galleryId
    options.galleryURL = galleryURL;    
    }
function onGalleryLoaded(e:Event):void{
    svAPI = Object(svLoader.content).api;
    svAPI.setSize(presseloader.mcFrame.width,presseloader.mcFrame.height);
}

Re: Load Galleries placed in different folders

If your gallery is in a different folder try setting loadGallery to load the gallery.xml without the path and
setting baseURL instead of galleryURL. Also remember to clear your browser's cache each time you make a change before you test it.

Mike Richards
SimpleViewer Support Team.

Re: Load Galleries placed in different folders

Thanks for your answer.
But i have a low level of AS3
Could you explain me more the function "baseURL" and its working ?

Thank you

Re: Load Galleries placed in different folders

baseURL is used to tell the gallery what folder the gallery resources are in, you can find more info in the linkes below.

http://simpleviewer.net/simpleviewer/su … .html#html

http://simpleviewer.net/simpleviewer/su … l#external

Mike Richards
SimpleViewer Support Team.

Re: Load Galleries placed in different folders

this solution seems to work with HTML solution.

I have a full Flash website which embed simpleviewer.

I have 10 galleries so 10 folders to manage them with sv manager.

On the root :
index.html
index.swf
simpleviewer.swf
>>press folder
   >>images folder
   >>thumbs thumbs
   >>gallery.xml
Maybe, it's the same system for flash, i should use baseURL instead of galleryURL, but where ?

import flash.display.*;
import flash.net.URLRequest;

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

var svAPI:Object;
var swfLoaded:Boolean = false;
var galleryURL:String;  ...............................................>>>MAYBE HERE
var svLoader:Loader = new Loader();
var galleryShowing:Boolean = true;

mcLoader.addChild(svLoader);
svLoader.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit);
loadGallery("presse.xml");   ...............................................>>>MAYBE HERE

function loadGallery(url:String) {

    galleryURL = url;   ...............................................>>>MAYBE HERE

    if (svAPI != null ) {
        svAPI.dispose();
    }
    svAPI = null;
    if (swfLoaded) {
        svLoader.unload();
    }

    var urlReq:URLRequest = new URLRequest("simpleviewer.swf");
    svLoader.load(urlReq);
    swfLoaded = true;
}

function onViewerInit(e:Event):void {
    trace("onViewerInit");

    Object(svLoader.content).addEventListener("svComplete", onGalleryLoaded);

    trace("setViewerFlashVars");
    var options:Object = Object(svLoader.content).embedOptions;
    //set gallery.xml url based on current galleryId   ............................................>>>MAYBE HERE
    options.galleryURL = galleryURL;

}

Re: Load Galleries placed in different folders

Well if you have 10 galleries in 10 folders with the standard configuration then each folder should have a gallery.xml. Since the xml name stays the same you wont need to feed that to the function that loads the gallery, instead you should feed it the folder name. Use find and replace to replace galleryURL with baseURL and then instead of passing a XML with loadGallery("presse.xml"); you pass a folder name, loadGallery("theFolderName");.

Mike Richards
SimpleViewer Support Team.

Re: Load Galleries placed in different folders

thank you very much, all my galleries are working, and i can manage them by svmanager  smile