Hey guys
I bought SlideshowPro and have created [URL=“http://secus.dk/fl/”]this gallery using it. However I’m having a lot of trouble getting the movie to scale to 100% width of the browser window.
I have already posted this on the SlideshowPro.net forums, but no one answers, not even when I email their support team.
Since this is something I paid money for, I’m probably not allowed to share the .fla file here, but I can show you the AS in the movie:
// Import transition classes
import mx.transitions.easing.*;
import mx.transitions.Tween;
// We'll Need Some Listeners
var sspListener = new Object();
var loadListen:Object = new Object();
var changeListener:Object = new Object();
// MovieClipLoader to pull in the thumbs
var thumb_Ldr:MovieClipLoader = new MovieClipLoader;
// Variables to hold the Current Album ID and a reference to the Current Image's MovieClip, respectfully
var curAlbum:Number;
var curImage:MovieClip;
// Reference to the MC we will create to put the thumbs in
var holder:MovieClip;
// Array that will hold all gallery data
var theArr:Array;
// Variables to hold how many thumbs we are loading and how many we have loaded so far
var toLoad:Number = 0;
var isLoad:Number = 0;
// Boolean: If the user is currently scrolling through the thumbs
var isScrolling:Boolean = false;
// Mask the Thumb MC
thumb_mc.setMask(mask_mc);
//
//// LISTENERS
//
// Triggered when the inital Gallery Data is Loaded
sspListener.onGalleryData = function(eventObject):Void {
// Fill theArr variable with the gallery data so we can use it whenever we need to
theArr = eventObject.data;
// Loop through the albums and fill the combobox with their labels
for (var i:Number = 0; i < theArr.length; i++) {
gallery_cb.addItem({label:theArr*[0].title});
}
}
// Triggered when an album is loaded
sspListener.onAlbumData = function(eventObject):Void {
// Save the album's id to a local variable
var id:Number = eventObject.data.id;
// Get how many images are in the album
var albumCount:Number = eventObject.data.totalImages;
trace(albumCount);
// Save the thumbnail path to a local variable
var tnPath = eventObject.data.tnpath;
// Loop through the albums
for (var i:Number = 0; i < theArr.length; i++) {
// if the id's match, we have found our album
if (theArr*[0].id == id) {
// Call load thumbs with the album index (i) and the other vars
loadThumbs(i, albumCount, tnPath);
// Update curAlbum variable
curAlbum = i;
}
}
}
// Triggered when a new image finished loading
sspListener.onImageData = function(eventObject):Void {
// Fade out the previous image
if (curImage != undefined)
{
new Tween(curImage,"_alpha",mx.transitions.easing.Strong.easeOut,curImage._alpha,50,1,true);
}
// Get the new images Movie Clip Name
var curImageStr:String = String(holder) + ".Image_"+String(curAlbum)+"_"+String(eventObject.data.number-1);
// Turns the above string into a MC reference via eval
curImage = eval(curImageStr);
// Tween the new curImage to full alpha
new Tween(curImage,"_alpha",mx.transitions.easing.Strong.easeOut,curImage._alpha,100,1.5,true);
// Formulate where the holder MC should slide to to keep the image centered
var holderTgt:Number = (curImage._x + (curImage._width/2))-275;
// If the user is not scrolling, slide the holder MC to center the image
if (!isScrolling)
new Tween(holder,"_x",mx.transitions.easing.Strong.easeOut,curImage._x, -(holderTgt),1.5,true);
}
// Event fires when each thumb has completely loaded AND initialized in the movie
loadListen.onLoadInit = function(target_mc:MovieClip) {
// Increment isLoad count
isLoad += 1;
// If all have loaded, run positionThumbs function and reset isLoad and toLoad vars
if (isLoad == toLoad) {
positionThumbs();
isLoad = 0;
toLoad = 0;
}
// Attach behaviors
target_mc.onRollOver = function() {
// User is now scrolling
isScrolling = true;
// If this is not the current image, fade it up on rollover
if (curImage._name != target_mc._name) {
new Tween(target_mc,"_alpha",mx.transitions.easing.Strong.easeOut,target_mc._alpha, 100,1,true);
}
// Slide the holder MC to center this image
var holderTgt:Number = (target_mc._x + (target_mc._width/2))-275;
new Tween(holder,"_x",mx.transitions.easing.Strong.easeOut,holder._x, -(holderTgt),1.5,true);
};
target_mc.onRollOut = function() {
// No longer scrolling
isScrolling = false;
// If this is not the current image, fade it back on rollout
if (curImage._name != target_mc._name) {
new Tween(target_mc,"_alpha",mx.transitions.easing.Strong.easeOut,target_mc._alpha, 50,1,true);
}
};
target_mc.onRelease = function() {
// If this is not the current image, tell SSP to load it
if (curImage._name != target_mc._name) {
// Split the Image's MC name into an theArray (e.g. Image_0_0)
var tempArr = target_mc._name.split("_");
// The first piece of the theArray is the album index, the second is the image index
var image:Number = Number(tempArr[2]);
// SSP loads the image
ssp.loadImageNumber(image);
}
};
};
// Change listener for combobox
changeListener.change = function(eventObject){
loading_mc._visible = true;
ssp.loadAlbum(eventObject.target.selectedIndex);
}
// Add all the listeners to their targets
ssp.addEventListener("onGalleryData", sspListener);
ssp.addEventListener("onImageData", sspListener);
ssp.addEventListener("onAlbumData", sspListener);
ssp.addEventListener("onImageRoll", sspListener);
gallery_cb.addEventListener("change", changeListener);
thumb_Ldr.addListener(loadListen);
//
//// FUNCTIONS
//
// Position Thumbs Function
function positionThumbs():Void {
// We'll need local variables for the height and width of each thumb
var loc_w:Number, loc_h:Number;
// We'll use this variable to position the thumb on the x-axis
var next_x:Number = 5;
// Loop through the thumbs
for (var i:Number = 0; i < toLoad; i++) {
// Get a reference to the thumbnail MC
var tgt_mc:MovieClip = eval(String(holder) + ".Image_"+String(curAlbum)+"_"+String(i));
// Set it's x property using the next_x var
tgt_mc._x = next_x;
// Set loc_h and loc_w
loc_h = tgt_mc._height;
loc_w = tgt_mc._width;
// Position the thumb centered vertically (assumes thumb are is 100px high)
tgt_mc._y = (120-loc_h)/2;
// Set the next_x for the next thumb
next_x += loc_w+15;
}
// All have loaded, fade out the loading thumbs message
loading_mc._visible=false;
}
// Load Thumbs Function
function loadThumbs(id:Number, count:Number, path:String):Void {
// Set toLoad var
toLoad = count;
// Set the base background MC to the needed width to hold all the thumbs (roughly)
thumb_mc.bg_mc._width *= (count+1);
// Create the holder MC
holder = thumb_mc.createEmptyMovieClip("holder", scrollMc.getNextHighestDepth());
// Local vars needed in the loop below
var tgt_mc:MovieClip, s_tgt:String, m_mc:MovieClip;
// Loop through and load thumbs
for (var i:Number = 0; i < count; i++) {
// Create MC to load thumb into
tgt_mc = holder.createEmptyMovieClip("Image_"+String(id)+"_"+String(i), 100+i);
// Get the URL to the thumbnail
var loc_path = path + theArr[id][1]*.tn;
// Use the MovieClipLoader to load the thumb into the MC
thumb_Ldr.loadClip(loc_path, tgt_mc);
// Set the new MC's alpha to 50
tgt_mc._alpha = 50;
}
}
I tried following gotoAndLearn’s video “Full browser flash” but had no luck with that.
Thanks in advance for any inputs.
MH