Topic: Change the xml path in embeded TiltViewer

Hi.
I have embedded a TiltViewer via a Loader in as3.
I also created a custom menu for my flash and i want to change the album path (xml gallery file) when i clicked the menu.
How can i do that ?
( just the code for changing xml path )

Re: Change the xml path in embeded TiltViewer

Use xmlURL to point to each gallery.xml, you can find an example, flash_embed_multiple.fla, in the flash_embed folder of the pro download.

var options:Object = Object(ldr.content).embedOptions;
options.xmlURL = "thefolder/gallery.xml";
Mike Richards
SimpleViewer Support Team.

Re: Change the xml path in embeded TiltViewer

Maybe I'm doing something wrong here.
I have loaded a tiltViewer with a custom xml gallery at first with the Event.INIT event and the code you provided.
Now i want to change the gallery file. When i remove the the loader ( that loaded tiltViewer on the stage ) i get away3D and onEnterFrame errors.
What should i do. I want to change the xml path several times on the runtime.

Re: Change the xml path in embeded TiltViewer

Please post the ActionScript code you are using.

Mike Richards
SimpleViewer Support Team.

Re: Change the xml path in embeded TiltViewer

i'm using this code for loading tiltViewer :

var ldr:Loader = new Loader();
var url:String = "res/com/tiltViewer.swf";
    var urlReq:URLRequest = new URLRequest(url);
    ldr.load(urlReq);
    ldr.contentLoaderInfo.addEventListener(Event.INIT, setOptions);
    function setOptions(e:Event)
    {
        var options:Object = Object(ldr.content).embedOptions;
        //Set example options here
        options.columns = 4;
        options.rows = 3;
        options.useReloadButton = false;
        options.bkgndTransparent = true;
        options.useFlickr = false;
        options.xmlURL = "res/xml/gallery1.xml";
        options.maxJPGSize = 800;
        options.backColor = "0xDDDDDD";
        options.bkgndInnerColor = "0x333333";
        options.bkgndOuterColor = "0xFFFFFF";
    }
    //this.setChildIndex(menu,this.numChildren-1);
}

and for loading another gallery ( changing xml path ) :

menu.addEventListener(MouseEvent.CLICK,menuEvents);
function menuEvents(evt:MouseEvent)
{
    if (evt.type == MouseEvent.CLICK)
    {
        // what code should i write here ???
    }
}

Re: Change the xml path in embeded TiltViewer

if (evt.type == MouseEvent.CLICK)
    {
        // what code should i write here ???
    }

Try something like optionsId = 2; loadGallery(); modifying the code below  to work with what you have.


From the flash_embed_multiple.fla example that comes with your pro download:

var optionsId:Number = 1;

//example buttons to switch between galleries
mcButton1.addEventListener(MouseEvent.CLICK,onClick1);
function onClick1(e:Event){
    optionsId = 1;
    loadGallery();
}
mcButton2.addEventListener(MouseEvent.CLICK,onClick2);
function onClick2(e:Event){
    optionsId = 2;
    loadGallery();
}
    
function loadGallery(){
    //unload last tiltviewer
    if  (Object(ldr.content)._app != null){
        Object(ldr.content)._app.kill();
        ldr.unload();
    }
    //load new tiltviewer
    ldr.load(urlReq);
}

//SET TILTVIEWER OPTIONS
//Set tilviewer options here. 
//These options will override options set via the HTML flashvars.
// For a description of config options see: http://www.airtightinteractive.com/projects/tiltviewer/config_options.html

function setOptions(e:Event){    
    var options:Object = Object(ldr.content).embedOptions;
    
    if (optionsId == 1){        
        //Set example options here
        options.columns = 3;
        options.rows = 2;    
        options.useReloadButton = false;
        options.bkgndTransparent = true;
        options.useFlickr = false;
        options.xmlURL = "gallery.xml";
        options.maxJPGSize = 640;
    }else if (optionsId == 2){
        //Set example options here
        options.columns = 4;
        options.rows = 3;    
        options.useReloadButton = true;
        options.bkgndTransparent = true;
        options.useFlickr = false;
        options.xmlURL = "gallery.xml";
        options.maxJPGSize = 640;
        options.frameColor = 0xFF00FF;    
    }
}
Mike Richards
SimpleViewer Support Team.

Re: Change the xml path in embeded TiltViewer

Thank you soooooooooooo much
I was stuck at this problem for two days and i nearly tried everything i knew.
I was trying to remove the loader from stage with " removeChild("ldr") " and not reaching anything.

This code was exactly what i was wanted :

function loadGallery(){
    //unload last tiltviewer
    if  (Object(ldr.content)._app != null){
        Object(ldr.content)._app.kill();
        ldr.unload();
    }
    //load new tiltviewer
    ldr.load(urlReq);
}