Topic: embed multiple galleries in flash CS5

dear pro's,

Im building a multiple gallery flash site at the moment (my old iWeb site www.joostweddepohl.nl got lost so thought i'd rebuild in flash). On the timeline I labeled my gallery sections. This is the AS I used.

var svAPI:Object;
var svLoader:Loader = new Loader();
addChild(svLoader);
svLoader.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit);
svLoader.load(new URLRequest("gallery/trouwen/svcore/swf/simpleviewer.swf"));

function onViewerInit(e:Event):void{
Object(svLoader.content).addEventListener("svComplete", onGalleryLoaded);
var options:Object = Object(svLoader.content).embedOptions;
options.galleryURL = "gallery/trouwen/gallery.xml";
}

function onGalleryLoaded(e:Event):void{
svAPI = Object(svLoader.content).api;
svAPI.setSize(1200,600);
}



Now..I get grey crosses where the thumbs and pics supposed to be. I made separate folders for all the galleries and traced to the folder (svLoader.load(new URLRequest("gallery/trouwen/svcore/swf/simpleviewer.swf")). It gave the following message:

[SV] Image Load Error for URL: images/IMG_1578.JPG
[SV] Thumb Load Error for: thumbs/IMG_1578.JPG attempting to load main image as thumb
etc..

What did i do wrong?   yikes

Also how can I give exact coordinates for the gallery so it'l fit on in my frame?

thnx in advance
joost

Re: embed multiple galleries in flash CS5

Check that the imageURL and thumbURL entries in your XML files are correct. If they are relative paths, they should be relative to the HTML page into which your container movie is embedded.
http://simpleviewer.net/simpleviewer/su … #trouble_2

Also how can I give exact coordinates for the gallery so it'l fit on in my frame?

SimpleViewer requires StageScaleMode.NO_SCALE and StageAlign.TOP_LEFT. If you wish to embed SimpleViewer Pro in a container movie, then you must modify the loading SWF to work with those parameters.
http://simpleviewer.net/simpleviewer/pr … html#flash

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

Hi Steve,

I'm new to all this so, sorry for the confusing story. By container movie, u mean my main .fla file right?
I understand the relative paths. In the main folder I have 8 separate gallery folders each containing the .xml, .html, .swf, an images folder, a thumbs folder. When saving a gallery with svBuilder it automatically makes a main folder (which i can give a name) an image/thumbs folder with the imageURL and thumbURL relative to the .xml or .html file right? So I can only have 1 images and thumbs folder. So would the solution be to copy all of the images into one "images folder" where the container movie is located? Or do I change the URL's in the gallery folders of each gallery? Or is my AS code incorrect?

this is what the folder looks like:
main folder/main.fla
main folder/main.swf
main folder/galleries/trouwen
main folder/galleries/trouwen/gallery.xml
main folder/galleries/trouwen/trouwen.html
main folder/galleries/trouwen/simpelviewer.swf
main folder/galleries/trouwen/images
main folder/galleries/trouwen/thumbs
main folder/galleries/amsterdam/gallery.xml
main folder/galleries/amsterdam/amsterdam.html
main folder/galleries/amsterdam/simpelviewer.swf
main folder/galleries/amsterdam/images
main folder/galleries/amsterdam/thumbs
etc..


Does it matter where I put the StageScaleMode.NO_SCALE and StageAlign.TOP_LEFT in action script?

thank a lot!
greets
joost

Re: embed multiple galleries in flash CS5

When saving a gallery with svBuilder it automatically makes a main folder (which i can give a name) an image/thumbs folder with the imageURL and thumbURL relative to the .xml or .html file right?

As created by svBuilder, the imageURL and thumbURL entires in each gallery's XML file will be relative to the gallery's 'index.html' file which is within the gallery folder.
Your imageURL and thumbURL entires in each gallery's XML file will need to be relative to the HTML page into which your 'main.swf' file is embedded.
This will require editing the XML files in a plain text editor but a couple of global search and replace actions per file should be sufficient to make the necessary changes.

So I can only have 1 images and thumbs folder.

No. You can have multiple 'images' and 'thumbs' folders as long as the imageURL and thumbURL entires point to the gallery images relative to your HTML page.

So would the solution be to copy all of the images into one "images folder" where the container movie is located? Or do I change the URL's in the gallery folders of each gallery?

Either solution would work (but not both at the same time).
If using a single 'images' folder, you would need to give each XML file a unique name and place them all alongside the 'images' folder and your HTML page.

Does it matter where I put the StageScaleMode.NO_SCALE and StageAlign.TOP_LEFT in action script?

Please see the 'simpleviewer_pro_220/examples/flash_embed/simpleviewer_flash_embed.fla' file for an example of embedding SimpleViewer-Pro in Flash.
Also, the 'Embedding in Flash' page here may prove useful: http://simpleviewer.net/simpleviewer/pr … html#flash

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

Hi Steve,

I've tried editing the XML files and got it to work. I have many galleries and lot's of images which I have to update regularly. so each time I add a photo to a gallery with svbuilder it will re-write the xml and I will have to edit all over again. I loved it when using iWeb cause it was fully automated. Now it's a bit time consuming editing all the XML files. Am I missing a easier method (you know how we love it easy!)?

As Im new 2 action script, I still don't understand how to position my galleries (center on stage). Is there a tutorial on this somewhere?

thanks!

Re: embed multiple galleries in flash CS5

Am I missing a easier method (you know how we love it easy!)?

Rather than using a galleryURL to point to an XML file, use a baseURL to point to a (self-contained) gallery folder.
All relative links within the gallery's XML file will then be relative to the specified baseURL (rather than the HTML file into which your SWF file is embedded).
Please see the 'FlashVar Options' section of the 'SimpleViewer-Pro Config Options' page for details: http://simpleviewer.net/simpleviewer/pr … .html#html
For example, try changing:

options.galleryURL = "gallery/trouwen/gallery.xml"; 

.. to:

options.baseURL= "gallery/trouwen/"; 

As Im new 2 action script, I still don't understand how to position my galleries (center on stage).

As SimpleViewer uses StageScaleMode.NO_SCALE and StageAlign.TOP_LEFT, ensure your container movie also uses these parameters and take a look at this page for advice on how to Center a movieclip on stage resize in AS3.

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

Hi Steve,

The baseURL worked! perfect!!
Also I worked around centering my gallery (I think) with the following code.

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

stage.addEventListener(Event.RESIZE,onResize);
onResize(null);

var svAPI:Object;
var svLoader:Loader = new Loader();
addChild(svLoader);
svLoader.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit);
svLoader.load(new URLRequest("gallery/abstract/svcore/swf/abstract.swf"));

function onViewerInit(e:Event):void{
Object(svLoader.content).addEventListener("svComplete", onGalleryLoaded);
var options:Object = Object(svLoader.content).embedOptions;
options.baseURL = "gallery/abstract/";
}


function onGalleryLoaded(e:Event):void{
   
    svAPI = Object(svLoader.content).api;
    svAPI.setSize(mcLoader.mcFrame.width,mcLoader.mcFrame.height);
}

function onResize(e:Event){   
   
    //resize mcFrame insude mcLoader
    mcLoader.mcFrame.width = stage.stageWidth - mcLoader.x -0;
    mcLoader.mcFrame.height = stage.stageHeight - mcLoader.y -50;
   
    //resize SV to match frame size
    if (svAPI != null ) svAPI.setSize(mcLoader.mcFrame.width,mcLoader.mcFrame.height);
   
}

1: when testing the movie, when I enter the gallery, everything else goes out of order. It's like the gallery is on top of everything.

2: this code only works on one gallery. When I try to copy this code and paste (change the URLrequest and the baseURL to the other gallery) it to another frame where another galleries starts, it doesn't work. I get the following warnings:

conflict exists with definition svAPI in namespace internal
conflict exists with definition svLoader in namespace internal
duplicate function definition
duplicate function definition
duplicate function definition

Re: embed multiple galleries in flash CS5

Please upload your complete .fla file so that I can download it and take a look (though I cannot be sure to solve your problems).

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

Sure! where do i upload my .fla file to?

thnx

Re: embed multiple galleries in flash CS5

where do i upload my .fla file to?

Anywhere that I will be able to download it from.
If you do not use any file-sharing service, just upload it to your own web space and post the URL to the file.
If your web host has restrictions on the type of files you are able to upload, try zipping the file first.

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

Hi steve,

I uploaded the file to http://www.megaupload.com/?d=HBIQ0VRG

thnx in advance

Re: embed multiple galleries in flash CS5

2: this code only works on one gallery. When I try to copy this code and paste (change the URLrequest and the baseURL to the other gallery) it to another frame where another galleries starts, it doesn't work. I get the following warnings:

conflict exists with definition svAPI in namespace internal
conflict exists with definition svLoader in namespace internal
duplicate function definition
duplicate function definition
duplicate function definition

In copying all the code for each gallery, the variables and functions have been duplicated. Variables have been declared twice and functions have duplicate names. Try giving all the variables and functions unique names.

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

Hi Steve,

I picked up my website this week. So I picked up where we left off. I've been digging through some action script lately. What I haven't found out is why when my gallery is loaded, there is something on the stage that blocks my buttons (a few buttons work). There is one button that works and brings my to a different section of the main timeline. But the gallery I loaded is still there. Do I need to unload? Also when I test movie, the mcLoader is way bigger than intended.

How do I set the size for the mcLoader and mcFrame?
I have my own navigation set up, do I need the API pallet?

Sorry for my inability to solve this. It's complicated.

thanks

Re: embed multiple galleries in flash CS5

Do I need to unload?

You can delete the SimpleViewer instance and free up allocated memory by using the SimpleViewer-Pro API method dispose(): http://simpleviewer.net/simpleviewer/pr … ml#methods

How do I set the size for the mcLoader and mcFrame?

Check the resize code in the example FLA to see how to handle resizing.

have my own navigation set up, do I need the API pallet?

Yes. You should use SimpleViewer-Pro API methods such as showNextImage() and showPreviousImage() to handle navigation.

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

Hi Steve,

Got one gallery going perfect now! By copying the code to all the frames where I want my galleries I have to give all variables and functions unique names right? Isn't there a simpler way to work around giving all functions unique names? can't I use a function multiple times?

thanks
Joost

Re: embed multiple galleries in flash CS5

this is the code for one gallery:


stop();

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;
var svLoader:Loader = new Loader();
var galleryShowing:Boolean = true;

mcLoader.addChild(svLoader);
svLoader.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit);
loadGallery("gallery/trouwen/");

function loadGallery(url:String){
    galleryURL = url;
    if (svAPI != null ) svAPI.dispose();
    svAPI = null;
    if (swfLoaded) svLoader.unload();
    var urlReq:URLRequest = new URLRequest("gallery/trouwen/svcore/swf/trouwen.swf");
    svLoader.load(urlReq);
    swfLoaded = true;
}

function onViewerInit(e:Event):void{
Object(svLoader.content).addEventListener("svComplete", onGalleryLoaded);
var options:Object = Object(svLoader.content).embedOptions;
options.baseURL = "gallery/trouwen/";
}

function onGalleryLoaded(e:Event):void{
    mcLoader.mcFrame.width = 1204
    mcLoader.mcFrame.height = 667
    svAPI = Object(svLoader.content).api;
    svAPI.setSize(mcLoader.mcFrame.width,mcLoader.mcFrame.height);
}

stage.addEventListener(Event.RESIZE,onResize);
onResize(null);

function onResize(e:Event){   
    mcBackground.width = stage.stageWidth;
    mcBackground.height = stage.stageHeight;
    mcLoader.mcFrame.width = stage.stageWidth - mcLoader.x - 0;
    mcLoader.mcFrame.height = stage.stageHeight - mcLoader.y - 0;
    if (svAPI != null ) svAPI.setSize(mcLoader.mcFrame.width,mcLoader.mcFrame.height);
   
}

for the second gallery:

stop();

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

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

var svAPI1:Object;
var swfLoaded1:Boolean = false;
var galleryURL1:String;
var svLoader1:Loader = new Loader();
var galleryShowing1:Boolean = true;

mcLoader.addChild(svLoader1);
svLoader1.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit1);
loadGallery1("gallery/events/");

function loadGallery1(url:String){
    galleryURL = url;
    if (svAPI1 != null ) svAPI1.dispose();
    svAPI1 = null;
    if (swfLoaded1) svLoader1.unload();
    var urlReq:URLRequest = new URLRequest("gallery/events/svcore/swf/events.swf");
    svLoader1.load(urlReq);
    swfLoaded1 = true;
}

function onViewerInit1(e:Event):void{
Object(svLoader1.content).addEventListener("svComplete", onGalleryLoaded1);
var options:Object = Object(svLoader1.content).embedOptions;
options.baseURL = "gallery/events/";
}

function onGalleryLoaded1(e:Event):void{
    mcLoader.mcFrame.width = 1204
    mcLoader.mcFrame.height = 667
    svAPI1 = Object(svLoader1.content).api;
    svAPI1.setSize(mcLoader.mcFrame.width,mcLoader.mcFrame.height);
}

stage.addEventListener(Event.RESIZE,onResize);
onResize(null);

function onResize1(e:Event){   
    mcBackground.width = stage.stageWidth;
    mcBackground.height = stage.stageHeight;
    mcLoader.mcFrame.width = stage.stageWidth - mcLoader.x - 0;
    mcLoader.mcFrame.height = stage.stageHeight - mcLoader.y - 0;
    if (svAPI1 != null ) svAPI1.setSize(mcLoader.mcFrame.width,mcLoader.mcFrame.height);
   
}

the second gallery doesn't unload, I can't find why.

Re: embed multiple galleries in flash CS5

can't I use a function multiple times?

Yes, functions can be used multiple times.
You should be able to have a single loadGallery() function to handle the loading of all your galleries, like the example in the SimpleViewer-Pro download package.
In the svAPI1 gallery, should you not be trying to dispose of the svAPI gallery (and vice versa)?
If you like, would you be able to zip your entire project and upload it somewhere?
I can't promise anything other than that I'll take a look.

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

Steve,

Thnx so much. If you just take a look. I know you are not a flash help desk ....! Just wanna get my site started.
project can be found here: [Link removed.]

let me know when u downloaded it, then I'll remove the link.

Cheers!
joost

Re: embed multiple galleries in flash CS5

File downloaded. Link removed from post above as requested.

Thank you for providing your project file.
However, having taken a look, I am unfortunately unable to provide you with a solution.
I think someone more familiar with Flash development and AS3 would be required to help further.
All I can do (which no doubt you have already looked at) is to point out the 'simpleviewer_flash_embed.fla' example from the SimpleViewer-Pro download package (in the 'examples/flash_embed' folder) which deals with loading multiple (two) galleries.
Perhaps you could use this as a starting template and work around it.

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

Hi Steve,


I'm very frustrated at this moment!! I spent so much time only getting simple viewer to work. With your help I'm almost there. I finally get the galleries to work in all the locations of the timeline. The only thing is that when I go from one gallery to another, the title text and thumbnail numbers won't go away. So after a couple of clicks, all the title text is on top of each other.
Any suggestions?

greets,
Joost

Last edited by weddje (2012-01-05 05:57:19)

Re: embed multiple galleries in flash CS5

No, unfortunately not. Sorry.

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

sorry, I got things to work in the meanwhile. so edited my last post....

Re: embed multiple galleries in flash CS5

Before you load a new gallery, are you disposing of and unloading the correct (existing) gallery?
It also sounds like your galleries have transparent backgrounds.
Perhaps simply giving each gallery a solid background (whether it be a color via the backgroundColor Embed Code PArameter or an image via the backgroundURL option) woud be a suitable workaround.

Steven Speirs
SimpleViewer Support Team.

Re: embed multiple galleries in flash CS5

well, I think I don't dispose or unload correctly. Otherwise when I load the next gallery, it would be a clean screen. Why would only the title text and thumbnail text stick?


stop();

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;
var svLoader:Loader = new Loader();
var galleryShowing:Boolean = true;

mcLoader.addChild(svLoader);
svLoader.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit);
loadGallery("gallery/trouwen/");


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{
Object(svLoader.content).addEventListener("svComplete", onGalleryLoaded);
var options:Object = Object(svLoader.content).embedOptions;
options.baseURL = "gallery/trouwen/";
}

function onGalleryLoaded(e:Event):void{
   
    mcLoader.mcFrame.width = 1204
    mcLoader.mcFrame.height = 667
    mcLoader.mcFrame.width = stage.stageWidth - mcLoader.x - 300;
    mcLoader.mcFrame.height = stage.stageHeight - mcLoader.y - 290;
    svAPI = Object(svLoader.content).api;
    svAPI.setSize(mcLoader.mcFrame.width,mcLoader.mcFrame.height);
   
}

next gallery


stop();

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

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


var swfLoaded1:Boolean = false;
var galleryURL1:String;
var svLoader1:Loader = new Loader();
var galleryShowing1:Boolean = true;

mcLoader.addChild(svLoader1);
svLoader1.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit1);
loadGallery1("gallery/events/");

function loadGallery1(url:String){
    galleryURL = url;
    if (svAPI != null ) svAPI.dispose();
    svAPI = null;
    if (swfLoaded1) svLoader1.unload();
    var urlReq:URLRequest = new URLRequest("simpleviewer.swf");
    svLoader1.load(urlReq);
    swfLoaded1 = true;
}

function onViewerInit1(e:Event):void{
Object(svLoader1.content).addEventListener("svComplete", onGalleryLoaded1);
var options:Object = Object(svLoader1.content).embedOptions;
options.baseURL = "gallery/events/";
}

function onGalleryLoaded1(e:Event):void{
    mcLoader.mcFrame.width = 1204
    mcLoader.mcFrame.height = 667
    mcLoader.mcFrame.width = stage.stageWidth - mcLoader.x - 300;
    mcLoader.mcFrame.height = stage.stageHeight - mcLoader.y - 290;
    svAPI = Object(svLoader1.content).api;
    svAPI.setSize(mcLoader.mcFrame.width,mcLoader.mcFrame.height);
}

and so on.

I've tried the backgroundColor and the backURL, both don't work.

thnx
Joost

Re: embed multiple galleries in flash CS5

My only thought is that in the loadGallery() function, should you not unload svLoader1 and vice versa (unload svLoader in loadGallery1())?.

Steven Speirs
SimpleViewer Support Team.