Jump to content

The thumbs are uploaded but not displayed in the flash.


Recommended Posts

As part of a project i am creating a photo gallery in xml and flash. I have made a form to upload the photos and automatically create online thumbnails with GD, the photos are uploaded,thumbnailed and added to xml, flash retrieves the other data from the xml but it doesn't display the thumbnails. I think  maybe is a mistake in actionscript. Is there anyone who can help me? I can post the actionscript code and the xml schema too or anything else you will need.

Thank you!

Ok here is the ActionScript code and the XML Schema:

 

var menuSpeed:Number = 6;
var menuDown:Button = menuDown_btn;
var menuUp:Button = menuUp_btn;
menuUp._alpha = 0;
menuUp.enabled = false;
var firstLook:Boolean = true;
var menuButtons:MovieClip = galleryMenu_mc.buttonsHolder_mc;
var galleryMask:MovieClip = galleryMenu_mc.galleryMask_mc;
galleryMask._height = 500;
var imagesHolder:MovieClip = imagesHolder_mc;
var descText:TextField = desc_txt;

var imagesInGallery:Array = new Array();
var galleryNames:Array = new Array();
var galleryIntros:Array=new Array();
var object:Array=new Array();
var descriptions:Array = new Array();
var thumb_path:Array = new Array();
var photo_path:Array = new Array();

var tracker:Number = new Number();
var whatIsLoading:String = new String();
var galleryBtnLeftMargin:Number = 10;
var galleryBtnUpperMargin:Number = 60;
var galleryBtnVSpace:Number = 23;
var thumbMarginX:Number = 96;
var thumbMarginY:Number = 68;
imagesHolder._x = 243;
imagesHolder._y = galleryBtnUpperMargin;
logo_mc._x = logo_mc._y=galleryBtnLeftMargin;
desc_txt._x = 243;
desc_txt._y = 400;
descText.text = "Click on a menu item on the left to load its thumbnails. Remember, you can click on a thumbnail only when all the thumbnails in a gallery have been loaded. When you click on a thumbnail to see the big image, clicking on the big image will close it and you will return to the gallery. Use the button(s) above the menu items to scroll through them.";

import flash.filters.DropShadowFilter;
var shadowEffect:DropShadowFilter = new DropShadowFilter(3, 45, 0x000000, 100, 3, 3, 1, 3);
var thumbsFilter:Array = [shadowEffect];
var loader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
loader.addListener(myListener);
myListener.onLoadInit = function(target:MovieClip) {
if (whatIsLoading == "thumb") {
currentThumbnail.percent_txt._visible = false;
currentThumbnail.filters = thumbsFilter;
thumbClickable();
tracker++;
if (tracker<howManyImages) {
loadThumbnail();
} else {
enableThumbs();
}
} else if (whatIsLoading == "big") {
target._alpha = 0;
displayBigImage.percent_txt._visible = false;
displayBigImage.filters = thumbsFilter;
bigClickable();
fadeIn();
}
};
myListener.onLoadProgress = function(target:MovieClip, loaded:Number, total:Number) {
percent = Math.floor(loaded/total*100);
if (whatIsLoading == "thumb") {
currentThumbnail.percent_txt._visible = true;
currentThumbnail.percent_txt.text = percent+"%";
} else if (whatIsLoading == "big") {
displayBigImage.percent_txt._visible = true;
displayBigImage.percent_txt.text = percent+"%";
}
};
var imageGallery:XML = new XML();
imageGallery.ignoreWhite = true;
imageGallery.onLoad = function(success) {
if (success) {
parseGalleries();
} else {
descText.text = "Sorry the image data just didn’t load.";
}
};
imageGallery.load("gallery.xml");
function parseGalleries():Void {
if (imageGallery.firstChild.nodeName == "gallery") {
var rootNode:XMLNode = imageGallery.firstChild;
for (i=0; i<rootNode.childNodes.length; i++)
{
if (rootNode.childNodes[i].nodeName == "category") 
{
currentGallery = rootNode.childNodes[i];

currentGalleryTitle = currentGallery.attributes.title;
currentGalleryIntro=currentGallery.attributes.intro;

imagesInGallery.push(currentGallery.childNodes.length);
galleryNames.push(currentGalleryTitle);
galleryIntros.push(currentGalleryIntro);


currentGalleryButton = galleryMenu_mc.buttonsHolder_mc.attachMovie("gallery section button", "galleryButton"+i, galleryMenu_mc.buttonsHolder_mc.getNextHighestDepth());
currentGalleryButton._x = 0;
currentGalleryButton._y = galleryBtnVSpace*i;
currentGalleryButton.sectionTitle_txt.text = "  "+currentGalleryTitle.toUpperCase();

for (j=0; j<currentGallery.childNodes.length; j++) 
{
if (currentGallery.childNodes[j].nodeName == "object")
{
currentObject = currentGallery.childNodes[j].attributes.title;
object.push(currentObject);

for(k=0; k<currentObject.childNodes.length;k++)
{
if (currentObject.childNodes[k].nodeName == "description")
{
currentDescription = currentObject.childNodes[k].firstChild;
descriptions.push(currentDescription);
}
else if(currentObject.childNodes[k].nodeName=="thumbnail_path")
{
current_Thumbnail = currentObject.childNodes[k].firstChild;
    thumb_path.push(current_Thumbnail);							   
}
else if (currentObject.childNodes[k].nodeName=="photo_path")
{
currentPhoto=currentObject.childNodes[k].firstChild;
photo_path.push(currentPhoto)
}
}
}
}
}
}
}
numberOfGalleries = i;
enableButtons(numberOfGalleries);
}
function enableButtons(numberOfGalleries:Number):Void {
for (i=0; i<numberOfGalleries; i++) {
pressedButton = galleryMenu_mc.buttonsHolder_mc["galleryButton"+i];
pressedButton.onRollOver = function():Void {
this.gotoAndStop(2);
};
pressedButton.onRollOut = function():Void {
this.gotoAndStop(1);
};
pressedButton.onPress = function():Void {
removeMovieClip(thumbsDisplayer);
removeMovieClip(displayBigImage);
tracker = 0;
thumbsDisplayer = imagesHolder.createEmptyMovieClip("thumbsDiplayer_mc", imagesHolder.getNextHighestDepth());
clickedGallery = Number(this._name.substr(13));
howManyImages = imagesInGallery[clickedGallery];
whichGallery = galleryNames[clickedGallery];
descText.text = galleryIntros[clickedGallery];

currentRow = 0;
currentColumn = 0;
loadThumbnail();
};
}
enableGalleryNavigation();
}

function loadThumbnail() {
currentThumbnail = thumbsDisplayer.attachMovie("thumbnail holder", "thumbnail"+(tracker+1), thumbsDisplayer.getNextHighestDepth());
target = currentThumbnail.thumbImage_mc;
if ((tracker%5) == 0 && tracker != 0) {
currentRow += 1;
}
if (currentColumn>3) {
currentColumn = 0;
} else if (tracker == 0) {
currentColumn = 0;
} else {
currentColumn += 1;
}
currentThumbnail._x = currentColumn*thumbMarginX;
currentThumbnail._y = currentRow*thumbMarginY;
currentThumbnail.percent_txt._visible = true;
thumbNumber = currentThumbnail._name.substr(9);
thumbPath =thumb_path[Number(thumbNumber)-1];
whatIsLoading = "thumb";
loader.loadClip(thumbPath,target);

}
function thumbClickable():Void {
currentThumbnail.onPress = function() {
bigNumber = this._name.substr(9);
displayBigImage = imagesHolder.attachMovie("big image holder", "bigImage_mc", imagesHolder.getNextHighestDepth());
target = displayBigImage.imageHolder_mc;
bigImagePath = photo_path[Number(bigNumber)-1];
whatIsLoading = "big";
disableThumbs();
loader.loadClip(bigImagePath, target);
if (clickedGallery>0) {
var descPosition:Number = 0;
for (i=0; i<clickedGallery; i++) {
descPosition += imagesInGallery[i];
}
descPosition = descPosition+Number(bigNumber)-1;
imageDesc = descriptions[descPosition];
} else {
imageDesc = descriptions[Number(bigNumber)-1];
}
descText.text = imageDesc;
};
currentThumbnail.enabled = false;
}
function disableThumbs():Void {
for (i=0; i<howManyImages; i++) {
thumbsDisplayer["thumbnail"+(i+1)].enabled = false;
}
}
function enableThumbs():Void {
for (i=0; i<howManyImages; i++) {
thumbsDisplayer["thumbnail"+(i+1)].enabled = true;
}
}
function bigClickable():Void {
displayBigImage.onPress = function() {
removeMovieClip(this);
enableThumbs();
descText.text = galleryIntros[clickedGallery];
};
}
function fadeIn():Void {
target.onEnterFrame = function():Void {
this._alpha += 10;
if (this._alpha>=100) {
delete this.onEnterFrame;
this._alpha = 100;
}
};
}
function enableGalleryNavigation():Void {
menuDown.onPress = function() {
if (firstLook) {
menuUp._alpha = 100;
menuUp.enabled = true;
firstLook = false;
}
var menuTop:Number = menuButtons._height-Math.abs(menuButtons._y);
if (menuButtons._y<=0 && menuTop>=galleryMask._height) {
var targetPos:Number = menuButtons._y-galleryMask._height;
menuDown.enabled = false;
menuUp.enabled = false;
menuButtons.onEnterFrame = function():Void {
menuButtons._y += (targetPos-menuButtons._y)/menuSpeed;
if (menuButtons._y<=(targetPos+0.) {
menuButtons._y = Math.round(targetPos);
delete menuButtons.onEnterFrame;
menuDown.enabled = true;
menuUp.enabled = true;
}
};
}
};
menuUp.onPress = function() {
var menuTop:Number = menuButtons._height-Math.abs(menuButtons._y);
if (menuButtons._y<0 && menuTop>0) {
var targetPos:Number = menuButtons._y+galleryMask._height;
menuDown.enabled = false;
menuUp.enabled = false;
menuButtons.onEnterFrame = function():Void {
menuButtons._y += (-menuButtons._y+targetPos)/menuSpeed;
if (menuButtons._y>=(targetPos-0.) {
menuButtons._y = Math.round(targetPos);
delete menuButtons.onEnterFrame;
menuDown.enabled = true;
menuUp.enabled = true;
}
};
}
};
}


 

 

The XML schema:

 

<?xml version="1.0"?>

<gallery>

<category title="hotele" intro="this is a photo gallery of hotels">

<object title="rogner">

<description><![CDATA[This is one of the most ....]]></description>

<thumbnail_path>foto/thumbs/hotele/tirana1.jpg</thumbnail_path>

<photo_path>foto/hotele/tirana1.jpg</photo_path>

</object>

</category>

<category title="restorante" intro="this is a photo gallery of restaurants">

<object title="juvenilja">

<description><![CDATA[This is one of the most ....]]></description>

<thumbnail_path>foto/thumbs/restorante/tirana2.jpg</thumbnail_path>

<photo_path>foto/restorante/tirana2.jpg</photo_path>

</object>

</category>

</gallery>

 

Any help would be very helpfull.

Thank you!

I think this would explain more:

 

<?xml version="1.0"?>

<gallery>

<category title="hotele" intro="this is a photo gallery of hotels">

<object title="thotel">

<description><![CDATA[This is one of the most ....]]></description>

<thumbnail_path>foto/thumbs/hotels/tirana1.jpg</thumbnail_path>

<photo_path>foto/hotels/tirana1.jpg</photo_path>

</object>

<object title="xhotel">

<description><![CDATA[This is one of the most ....]]></description>

<thumbnail_path>foto/thumbs/hotels/tirana2.jpg</thumbnail_path>

<photo_path>foto/hotels/tirana2.jpg</photo_path>

</object>

</category>

 

</gallery>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.