Topic: Gallery keeps refreshing/reloading in Flash

Hello,

I recently purchased simpleviewer pro and am working in a full flash website. The navigation is built with frame labels on the main timeline, and I'd prefer to not build the whole entire site structure over again if possible!

I have the main slideshow on the home page which seems to be working fine, just some resizing issues I can tweak, and then later on in my main timeline, the portfolio page contains a movie clip with a secondary navigation, where the mcLoader is located.

I copied the code from the flash_embed example and tweaked it accordingly (or so I think, as I am a newbie to AS3)

As I mentioned, the original slideshow works fine, but I have about 7 different sections that need individual galleries. Here is a link to the site: (Don't mind any layout issues, as I'm focusing on the gallery problem.

http://studio27designs.com/kiracroninph … _NEW2.html

here is my code for the multiple galleries: I even left the comments in to guide me, but still can't fig. it out

//import required classes
import flash.display.*;
import flash.net.URLRequest; 

//turn off stage auto resizing
//SimpleViewer requires these settings to function correctly
//scaling is handled via the onResize handler (see bottom of this code)
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;        

//Init variables
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
var galleryShowing:Boolean = true;

//add svLoader to the "mcLoader" stage movieclip on the main timeline
mcLoader.addChild(svLoader);
//listen for SWF loaded
svLoader.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit);
//load 1st gallery
loadGallery("couples.xml");

/**
* This function loads the SimpleViewer SWF
*/
function loadGallery(url:String){
    
    galleryURL = url;
    
    //unload previous simpleviewer instance
    if (svAPI != null ) svAPI.dispose();
    svAPI = null;
    //flash 9 - unload
    if (swfLoaded) svLoader.unload();
    //Flash 10 - unloadAndStop 
    //if (_viewerLoaded) svLoader.unloadAndStop();
            
    //load simpleviewer swf
    var urlReq:URLRequest = new URLRequest("simpleviewer.swf");
    svLoader.load(urlReq);
    swfLoaded = true;
}


/**
* Fired when preloader is available
* Can set flashvars at this point
*/ 
function onViewerInit(e:Event):void{
    //trace("onViewerInit");
    
    //listen for
    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;    
    
}
        
        
/**
 * Fired when gallery has completly loaded (SWF +  XML)
 * API is now available.
 */ 
function onGalleryLoaded(e:Event):void{
    
    svAPI = Object(svLoader.content).api;
    svAPI.setSize(mcLoader.mcFrame.width,mcLoader.mcFrame.height);
    //svAPI.setSize(550,550);
    
    
}


//Init Button Click Handlers
baby_btn.addEventListener(MouseEvent.CLICK,loadGallery1);
mat_btn.addEventListener(MouseEvent.CLICK,loadGallery2);
kid_btn.addEventListener(MouseEvent.CLICK,loadGallery3);
fam_btn.addEventListener(MouseEvent.CLICK,loadGallery4);
cpl_btn.addEventListener(MouseEvent.CLICK,loadGallery5);
port_btn.addEventListener(MouseEvent.CLICK,loadGallery6);

//Button Click Handlers
function loadGallery1(e:Event){
    loadGallery("baby.xml");
}

function loadGallery2(e:Event){
    loadGallery("maternity.xml");
}
function loadGallery3(e:Event){
    loadGallery("kids.xml");
}
function loadGallery4(e:Event){
    loadGallery("family.xml");
}
function loadGallery5(e:Event){
    loadGallery("couples.xml");
}
function loadGallery6(e:Event){
    loadGallery("portrait.xml");
}

Any help is greatly appreciated, I've been spending a day and a half on this!

Re: Gallery keeps refreshing/reloading in Flash

Just incase anyone else ever runs into this issue, I figured it out....

I had an extra frame in my movieclip that was causing the reload to happen. Everything works great now!