Topic: gallerie not loading after change

I created 5 galleries in a flash website.

The first gallery is loading but after I change it to a different one, it only says its loaded but nothing shows.

Any ideas?

Here is an online link:
http://www.sandradussault.com/new/#/work/

Thanks

Last edited by freeflysandra (2009-08-14 18:27:41)

Re: gallerie not loading after change

Without seeing the code I can only guess, but it looks like your buttons are the issue as the web gallery loads but if I click any of the buttons including web the flash breaks. Did you look at the multiple gallery example in pro download folder simpleviewer_pro\examples\Flash Embed? I see you are using SWFAddress for the rest of your site, you could also take a look at my SWFAddress example for integration with SimpleViewer.

Mike Richards
SimpleViewer Support Team.

Re: gallerie not loading after change

Hi Miker, thank for you reply.

I did experiment with the multiple galleries, I have one loader who loads 5 different .swf.

Here is my code dealing with the galleries:

var workPages:Array=[web_mc,print_mc,identity_mc,illustration_mc,misc_mc];

for (var i:uint = 0; i < workPages.length; i++) {
    workPages[i].visible=false;
}
web_mc.visible=true;

workButtons.addEventListener(MouseEvent.CLICK, gotoPage);

function gotoPage(event:MouseEvent):void {
    var btnName:String=event.target.name;
    btnName=btnName.slice(0,btnName.indexOf("_"));
    for (var i:uint = 0; i < workPages.length; i++) {
        workPages[i].visible=false;
    }
    getChildByName(btnName+"_mc").visible=true;
    trace(event.target.name);

        if (webIDLoader.content!=null) {
            webIDLoader.unload();
            trace("unloaded");
        }

        webIDLoader = new Loader();
        var webIDReq:URLRequest=new URLRequest("viewer"+ btnName +".swf")
        webIDLoader.load(webIDReq);
        webIDLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, webIDLoaded);

function webIDLoaded(event:Event):void {
    addChild(webIDLoader);
}
        trace("loaded again");
}


///first gallery to load

var webIDReq:URLRequest=new URLRequest("viewerweb.swf");
var webIDLoader:Loader = new Loader();
webIDLoader.x=0;
webIDLoader.y=0;

webIDLoader.load(webIDReq);

webIDLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, webIDLoaded);

function webIDLoaded(event:Event):void {
    addChild(webIDLoader);
}

Re: gallerie not loading after change

Oh and thank for the SWFAddress, I will have a look once I figure my galleries issues!

Re: gallerie not loading after change

Out of curiosity what made you decide to loading a separate viewer.swf for each gallery? The first real issue I see is duplicate variable declaration and the function webIDLoaded is declared twice.

One way to simplify what you have written would be to give your buttons an instance name such as web_btn, print_btn, identity_btn, illustration_btn, and misc_btn and use something like the following code.

var webIDReq:URLRequest;
var webIDLoader:Loader;

function gotoPage(gallName:String):void {
 
        if (webIDLoader.content!=null) {
            webIDLoader.unload();
            trace("unloaded");
        }

        webIDLoader = new Loader();
        webIDReq:URLRequest=new URLRequest("viewer"+ gallName +".swf")
        webIDLoader.load(webIDReq);
        webIDLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, webIDLoaded);
        
        trace("loaded again");
}

function webIDLoaded(event:Event):void {
    addChild(webIDLoader);
}

///first gallery to load
gotoPage("web");


web_btn.onRelease = function(){ 
    gotoPage("web");   
}
print_btn.onRelease = function(){ 
    gotoPage("print");   
}
identity_btn.onRelease = function(){ 
    gotoPage("identity");   
}
illustration_btn.onRelease = function(){ 
    gotoPage("illustration");   
}
misc_btn.onRelease = function(){ 
    gotoPage("misc");   
}
Mike Richards
SimpleViewer Support Team.

Re: gallerie not loading after change

Hi Mike,

Thanks again for your reply.

To be honest, there is no real reason why I have different loaders. Do you think it is less effective?

The code you have written is giving me a bunch of errors. Is it AS2? I dont think the onRelease code is compatible with AS3.

My buttons do have these instance names, they are in an array named workButtons. This array is powered by a custom class.

I would prefer to keep them as is, and write one function to handle them all. What do you think?

import com.sd.ButtonSet;

var workButtons:ButtonSet = new ButtonSet();
workButtons.addButtons([web_btn, print_btn, identity_btn, illustration_btn]);
addChild(workButtons);
workButtons.buttonMode=true;

Re: gallerie not loading after change

It wasn't really complete code just a start for simplifying what you posted, you would probably need to make changes to it in order to get it to function with your app. I was assuming you were using AS2, are you using AS3? If you are using AS3, as far as I know you can not use a AS2 SWF (ie SimpleViewer) with AS3 out of the box you have to use some code to help with communications as they use two different virtual machines. Really it would be much easier on you if you did it is AS2, if not you need to use something like SWFBridge.

Mike Richards
SimpleViewer Support Team.

Re: gallerie not loading after change

Hi Mike,

I am using AS3, yes. I would not rewrite my whole website in AS2 as I am much more familiar with AS3.
But now that you mention the bridge, it makes sense and it is probably the course of my problem. I did not know about it.

Thanks for this link, I will give it a try and let you know how it goes.