RSS
Facebook
G+

Buscador de IntercambioSOS:


Retroceder   Foro de Ayuda IntercambiosvirtualeS > Soporte Sobre: Educación & Entretenimiento > Zona Académica > Programación
Comunidad

 
 
Herramientas Desplegado
Antiguo 17-nov-2010     #1
Predeterminado crear xml desde php con data de la base de datos

Este es un ejemplo para una galeria de imagenes dinamicas mediante php que genera un xml que luego es leido desde un flash con actionscript

Tabla en la Base de datos

Código PHP:
CREATE TABLE IF NOT EXISTS `galeria` (
  `
idint(11NOT NULL AUTO_INCREMENT,
  `
categoryint(4NOT NULL,
  `
datedate NOT NULL,
  `
titlevarchar(50NOT NULL,
  `
descrivarchar(50NOT NULL,
  `
thumbvarchar(50NOT NULL,
  `
imgvarchar(50NOT NULL,
  
PRIMARY KEY (`id`)
ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=25 

codigo flash

deben de tener estas tres clases

"mc_tween2.as"
"xmlsa.as"
"timer.as"

Código PHP:
stop();
// include assets
#include "mc_tween2.as"
#include "xmlsa.as"
#include "timer.as"


// two views ? catView : thumbView
var viewMode "catView"// when page is first viewed show all the categories.
var viewRand true// on/off random preview
var catCol 4// number of columns for category
var numCatDisplay 12// max number of categories to show per page
var numThumbDisplay 12// max number of thumbnails to show per page
var catColXgap 8// gap between categories
var catColYgap 180;
var 
dropDown false;

var 
curImage 0;
var 
curCat 0;

// slideshow switch
var autoSlide true;
// default transition speed
var defTranSpeed 300;

catView_btn._alpha 0;

// load the xml data
gallery = new XMLSA();
gallery.load("http://localhost:81/rutadedondetenganlaclase/class/gallery.php");
gallery.onLoad = function(ok){
    if (
ok) {
        
parseXml();
    } else {
        
// error branch
        
trace("error");
    }
}


/* loading stylesheet // not being used for image gallery but can be added later
function loadCss() {
    styles = new TextField.StyleSheet();
    css = "styles.css";
    styles.load(css);
    styles.onLoad = function(loaded) {
        if (loaded) {
            cssLoaded = true;
        } else {
            cssLoaded = false;
        }
        parseXml();
    }
}
*/


function parseXml() {
    
//DEBUG
    //trace(gallery.dump());
    
    
myGallery = new Array();
    
    
// gallery title
    
galleryTitle gallery.attributes.title;
    
title_txt.text galleryTitle;
    
    
// thumbanil directory
    
thumbDir gallery.attributes.thumbDir;
    
// image directory
    
imageDir gallery.attributes.imageDir;
    
// random ? true : false
    
viewRandom gallery.attributes.random;
    if(
viewRandom == "true") {
        
viewRand true;
    } else {
        
viewRand false;
    }
    
// parse information
    
catTotal gallery.category.length;

    for(var 
i=0i<catTotali++) { //looping through categories
        
myGallery[i] = new Array();
        
myGallery[i]["name"] = gallery.category[i].attributes.name;
        
myGallery[i]["image"] = new Array();
        
//trace(myGallery[i]["name"]);
        
var imageCount gallery.category[i].image.length;
        for(var 
k=0k<imageCountk++) { //looping through images
            
myGallery[i]["image"][k] = new Array();
            
myGallery[i]["image"][k]["date"] = gallery.category[i].image[k].date.getValue();
            
myGallery[i]["image"][k]["title"] = gallery.category[i].image[k].title.getValue();
            
myGallery[i]["image"][k]["desc"] = gallery.category[i].image[k].desc.getValue();
            
myGallery[i]["image"][k]["thumb"] = gallery.category[i].image[k].thumb.getValue();
            
myGallery[i]["image"][k]["img"] = gallery.category[i].image[k].img.getValue();
            
//trace(myGallery[i]["image"][k]["date"]);
        
}
    }
    
    
    
// determine the number of pages needed
    
if(catTotal numCatDisplay) {
        
catNumPages Math.ceil(catTotal/numCatDisplay);
    } else {
        
// if categories are less than the limit only one page is needed
        
catNumPages 1;
    }

    
// start from first page
    
catPageCounter 1;
    
    
// start from 0;
    
var pos 0;
    
    
// output page status
    
page_txt.text catPageCounter+" of "+catNumPages;
    
    
prevBtn(catPageCounter);
    
nextBtn(catPageCountercatNumPages);
    
    
//disable catViewBtn
    
catView_btn.enabled false;
    
    
loadCat(pos);
    
loadDropDown();

    
catView_btn.onRelease = function() {
        
catPageCounter 1;
        
        
_root.viewMode "catView";
        
        
loadCat(0);
        
catView_btn.enabled false;
        
catView_btn.alphaTo(01);
        
dropDownBtn_mc.catName_txt.text "Choose a category";
        if(
dropDown) {
            
doDropDown();
        }
        
// output page status
        
page_txt.text catPageCounter+" of "+catNumPages;
        
prevBtn(catPageCounter);
        
nextBtn(catPageCountercatNumPages);
    }    
}



function 
enableCatViewBtn() {
    
catView_btn.enabled true;
    
catView_btn.alphaTo(1001);
}




function 
loadDropDown() {
    
    
// if less than 7 categories, shorten the dropdown bg
    
if(catTotal 8) {
        
// height of each category buttons
        
var catBtnHeight 20+3// include the gaps
        
var bgHeight catTotal catBtnHeight;
        
bgHeight += 20//include the top padding
        
dropDown_mc.bg_mc.tween("_height"bgHeight1);
    }
    
    
    var 
temp dropDown_mc.createEmptyMovieClip("temp"_root.getNextHighestDepth());
    
    var 
i=0;
    
    
temp.onEnterFrame = function(){
        if(
catTotal>i){
            
            
//trace(i);
            
var DropDownBtn dropDown_mc.catBtn_mc.attachMovie("dropDownBtn""dropDownBtn_mc"+ii);
            
            
DropDownBtn._alpha 0;
            
DropDownBtn.alphaTo(1003);
            
            
DropDownBtn._y Math.round(Number(DropDownBtn._height+3) * i);

            
DropDownBtn.catName_txt.text myGallery[i]["name"];
        
            
DropDownBtn.onRollOver = function() {
                
this.bg_mc.colorTo(0x10bddc0.2);
                
this.catName_txt.colorTo(0xddfaff0.2);
            }
            
            
DropDownBtn.onRollOut = function() {
                
this.bg_mc.colorTo(0xebeeef3);
                
this.catName_txt.colorTo(0x3333330.2);
            }
            
            var 
totalImg myGallery[i]["image"].length;
            
            
// when user clicks on one the categories, show thumbanils of that category
            
DropDownBtn.total total;
            
DropDownBtn.chosenCat i;
            
DropDownBtn.onRelease = function() {
                
dropDownBtn_mc.catName_txt.text myGallery[this.chosenCat]["name"];
                
activateCat(thisthis.chosenCat);
                
viewMode "thumbView"// change mode to thumb view
                
showTnView(this.chosenCattotalImg);
                
                
enableCatViewBtn();
            }
            
            
i++
        } else {
            
delete this.onEnterFrame;
            
this.removeMovieClip();
        }
    }
}






    
// function determining whether to enable page buttons or not // if more than one page is needed enable the buttons

function prevBtn(counter) {
    
trace(counter);
    if(
counter 1) {
        
prev_btn.enabled true;
        
prev_btn.gotoAndStop(2);
        
    } else if(
counter == 1) {
        
prev_btn.btn_mc.icon_mc.colorTo(0x3333330.5);
        
prev_btn.btn_mc.bg_mc.colorTo(0xffffff0.5);
        
prev_btn.enabled false;
        
prev_btn.gotoAndStop(1);
        
        
    }

}

function 
nextBtn(counterpages) {

    
    if(
counter pages) {
        
next_btn.enabled true;
        
next_btn.gotoAndStop(2);
        
    } else if(
counter == pages) {
        
next_btn.btn_mc.icon_mc.colorTo(0x3333330.5);
        
next_btn.btn_mc.bg_mc.colorTo(0xffffff0.5);
        
next_btn.enabled false;
        
next_btn.gotoAndStop(1);
    }
    
}



prev_btn.onRelease = function() {
    
// hide the dropdown if it's open
    
if(dropDown) {
        
doDropDown();
    }
    
    if(
viewMode == "catView") {
        if(
catPageCounter 1) {
            
catPageCounter--;
        }
        
        
prevBtn(catPageCounter);
        
nextBtn(catPageCountercatNumPages);
        
//trace(catPageCounter);
        
        // recaculate the start position
        
var pos = (catPageCounter*numCatDisplay)-numCatDisplay;
        
//trace(pos);
        // output page status
        
page_txt.text catPageCounter+" of "+catNumPages;
        
        
loadCat(pos);
    } else if(
viewMode == "thumbView") {
        
// hide the dropdown if it's open
        
if(dropDown) {
            
doDropDown();
        }
        
        
            if(
thumbPageCounter 1) {
                
thumbPageCounter--;
            }
            
//trace(thumbPageCounter);
            
            // recaculate the start position
            
var pos = (thumbPageCounter*numThumbDisplay)-numThumbDisplay;
            
            
// output page status
            
page_txt.text thumbPageCounter+" of "+thumbNumPages;
            
            
// enable/disable page buttons
            
prevBtn(thumbPageCounter);
            
nextBtn(thumbPageCounterthumbNumPages);
            
            
remove();
            
showThumbs(curCatpos);
    }
    
}
prev_btn.onRollOver = function() {
    
this.btnRollOver();
}
prev_btn.onRollOut = function() {
    
this.btnRollOut();
}




next_btn.onRelease = function() {
    

    
    
// hide the dropdown if it's open
    
if(dropDown) {
        
doDropDown();
    }
    
    
    
    if(
viewMode == "catView") {
        
        
trace('12313');
        
        if(
catPageCounter catNumPages) {
            
catPageCounter++;
        }
        
//trace(catPageCounter);
        
prevBtn(catPageCounter);
        
nextBtn(catPageCountercatNumPages);
        
// recaculate the start position
        
var pos = (catPageCounter*numCatDisplay)-numCatDisplay;
        
//trace(pos);
        // output page status
        
page_txt.text catPageCounter+" of "+catNumPages;
        
loadCat(pos);
    } else if(
viewMode == "thumbView") {
        
trace('aaa');
        
        
// hide the dropdown if it's open
        
if(dropDown) {
            
doDropDown();
        }
        
        
            
            if(
thumbPageCounter thumbNumPages) {
                
thumbPageCounter++;
            }
            
            
// recaculate the start position
            
var pos = (thumbPageCounter*numThumbDisplay)-numThumbDisplay;
            
            
// output page status
            
page_txt.text thumbPageCounter+" of "+thumbNumPages;
            
            
// enable/disable page buttons
            
prevBtn(thumbPageCounter);
            
nextBtn(thumbPageCounterthumbNumPages);
            
            
remove();
            
showThumbs(curCatpos);
    }

}
next_btn.onRollOver = function() {
    
this.btnRollOver();
}
next_btn.onRollOut = function() {
    
this.btnRollOut();
}






// function to initialize the category buttons
function loadCat(pos) {
        
    
catWrap_mc.removeMovieClip();
    
imgWrap_mc.removeMovieClip();
    
    var 
catWrap _root.createEmptyMovieClip("catWrap_mc"_root.getNextHighestDepth());
    var 
imgWrap _root.createEmptyMovieClip("imgWrap_mc"_root.getNextHighestDepth());
    
catWrap._x 61;
    
catWrap._y 120;
    
imgWrap._x 58;
    
imgWrap._y 120;
    
    
dropDown_mc.swapDepths(_root.getNextHighestDepth());
    
dropDownBtn_mc.swapDepths(_root.getNextHighestDepth());
    
    
    
//get the total number of rows
    
var numRows catTotal/catCol;
    
    var 
xnum catCol;
    var 
ynum numRows;
    
    var 
xgap catColXgap;
    var 
ygap catColYgap;
    var 
ox 0
    
var oy 0
    
var total xnum*ynum
    
    
var i=pos;
    var 
j=0// used to reset the position
    
    
var taco i+numCatDisplay;
    
//trace(pos);
    
    
var temp _root.createEmptyMovieClip("temp"_root.getNextHighestDepth());
    
temp.onEnterFrame = function(){
        if(
i<taco && i<catTotal){
            
            
//trace(i);
            
var myCat catWrap.attachMovie("cat""cat_mc"+ii);
            var 
myImg imgWrap.attachMovie("thumb""thumb_mc"+ii);
            
            
// mc covering thumbnails to hide dynamic text
            
myImg.tnHider_mc.alphaTo(03);
            
            
myCat._alpha 0;
            
myImg._alpha 0;
            
myCat.alphaTo(1003);
            
myImg.alphaTo(1003);
            
            
myCat._x Math.round(ox + (j%xnum)*(xgap myCat._width));
            
myCat._y Math.round(oy int(j/xnum)*ygap);
            
            
myImg._x Math.round(ox + (j%xnum)*(xgap myImg._width-4)); // subtract 9 : because of drop shadow it adds to the width of box
            
myImg._y Math.round(oy myCat._y 25);
            
            var 
totalImg myGallery[i]["image"].length;
        
            if(
viewRand) {
                
//get a random number between total number of images from each categories
                
var RandImgNum random(myGallery[i]["image"].length);
                var 
CurImage RandImgNum;
                var 
ImgDate myGallery[i]["image"][RandImgNum]["date"];
                var 
ImgTitle myGallery[i]["image"][RandImgNum]["title"];
                var 
ImgDesc myGallery[i]["image"][RandImgNum]["desc"];
                var 
ImgThumb myGallery[i]["image"][RandImgNum]["thumb"];
                var 
ImgFull myGallery[i]["image"][RandImgNum]["img"];
                
            } else {
                var 
CurImage 0;
                
// 0 == most recently added image <- controlled by php
                
var ImgDate myGallery[i]["image"][0]["date"];
                var 
ImgTitle myGallery[i]["image"][0]["title"];
                var 
ImgDesc myGallery[i]["image"][0]["desc"];
                var 
ImgThumb myGallery[i]["image"][0]["thumb"];
                var 
ImgFull myGallery[i]["image"][0]["img"];
            }
            
            
//trace(ImgDesc);
            
            
myCat.cat_txt.text myGallery[i]["name"];
            
myCat.total_txt.text totalImg;
            
            
myImg.title_txt.text =  ImgTitle;
            
myImg.date_txt.text =  ImgDate;
            
            
//need to send these to display thumbnails when user clicks the thumbnail from cat view
            
myImg.empty_mc.total total;
            
myImg.empty_mc.curCat i;
            
            
myImg.empty_mc.curImage CurImage;

            
myImg.empty_mc.imgDesc ImgDesc;
            
myImg.empty_mc.thumbToLoad ImgThumb;
            
myImg.empty_mc.imgToLoad ImgFull;
            
myImg.empty_mc.loadThumb();
        
        
            
myCat.onRollOver = function() {
                
this.catBG_mc.colorTo(0x1b4d700.5);
                
this.cat_txt.colorTo(0xb5d9f20.5);
            }
            
            
myCat.onRollOut = function() {
                
this.catBG_mc.colorTo(0x1919196);
                
this.cat_txt.colorTo(0xa5a5a50.5);
            }
            
            
// when user clicks on one the categories, show thumbanils of that category
            
myCat.total total;
            
myCat.chosenCat i;
            
myCat.onRelease = function() {
                
dropDownBtn_mc.catName_txt.text myGallery[this.chosenCat]["name"];
                
activateCat(thisthis.chosenCat);
                
viewMode "thumbView"// change mode to thumb view
                
showTnView(this.chosenCattotalImg);
                
                
enableCatViewBtn();
            }
            
            
j++
            
i++
        } else {
            
delete this.onEnterFrame;
            
this.removeMovieClip();
        }
    }
}



function 
activateCat(itemnum) {
    if (
currentItem != false) {
        
deactivateCat(num);
    }
    
    
// hide the dropdown if it's open
    
if(dropDown) {
        
doDropDown();
    }
    
    
currentItem item;

    
currentItem.catBG_mc.colorTo(0x1b4d700.5);
    
currentItem.cat_txt.colorTo(0xb5d9f20.5);
    
    
currentItem.bg_mc.colorTo(0x10bddc0.2);
    
currentItem.catName_txt.colorTo(0xddfaff0.2);
    
    
/*
    dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].bg_mc.colorTo(0x10bddc, 0.2);
    dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].catName_txt.colorTo(0xddfaff, 0.2);
    dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].enabled = false;
    */
    
currentItem.enabled false;
}

function 
deactivateCat(num) {

    
// for catView btns
    
currentItem.catBG_mc.colorTo(0x1919196);
    
currentItem.cat_txt.colorTo(0xa5a5a50.5);
    
    
currentItem.bg_mc.colorTo(0xebeeef3);
    
currentItem.catName_txt.colorTo(0x3333330.2);
    
// for dropdown buttons
/*
    dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].bg_mc.colorTo(0xebeeef, 3);
    dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].catName_txt.colorTo(0x333333, 0.2);
    dropDown_mc.catBtn_mc["dropDownBtn_mc"+num].enabled = true;
    */
    
currentItem.enabled true;
    
currentItem undefined;
}


MovieClip.prototype.loadThumb = function() {

    var 
target this;
    var 
imgDesc this.imgDesc;
    var 
thumbToLoad this.thumbToLoad;
    var 
imgToLoad this.imgToLoad;
    var 
curImage this.curImage;
    var 
curCat this.curCat;
    var 
thumbTotal this.total;
    
    
this.loadMovie(thumbDir+thumbToLoad);
    var 
temp this._parent.createEmptyMovieClip("temp"this._parent.getNextHighestDepth());
    
    
temp.onEnterFrame = function() {
        var 
loaded target.getBytesLoaded();
        var 
total target.getBytesTotal();
        var 
perc Math.round(loaded/total*100);
        
        
target._parent.bar_mc._yscale perc;
        
        
//trace(perc);
        
if(perc == 100) {
            
target._parent.bar_mc.alphaTo(05);
            
            
target.curCat curCat;
            
target.curImage curImage;
            
target.imgDesc imgDesc;
            
target.imgToLoad imgToLoad;
            
target.maxWidth 179;
            
target.maxHeight 55;
            
target.thumbTotal thumbTotal;
            
            
target.shrinkImg();
            

            
delete this.onEnterFrame;
            
temp.removeMovieClip();
        }
    }
}


MovieClip.prototype.shrinkImg = function (){
    
    
// init pos and alpha of click_txt
    
this._parent.click_txt._alpha 100;
    
//this._parent.click_txt.roundedYSlideTo(15, 0.2);
    
    
var orgWidth this._width;
    var 
orgHeight this._height;
    
    var 
orgX this._x;
    var 
orgY this._y;

    
    
// resizeImg object is returned by resizeToFit prototype function and saved as myImage;
    
var myImage this.resizeToFit();
    
this.tween(["_width""_height"], [myImage.newWidthmyImage.newHeight], 1);


    
// slide the image to the middle point y
    
var yMiddle = -(Number(myImage.newHeight/2)-40);
    
//trace(yMiddle);
    //this.ySlideTo(yMiddle, 2);
    
    
    
this.onRollOver = function() {
        
//this._parent.click_txt.alphaTo(100, 2);
        
this._parent.click_txt.roundedYSlideTo(-81);
        
// make it dark
        
this._parent.rollover_mc.alphaTo(700.5);
        
//this.tween(["_width", "_height"], [myImage.newWidth+20, myImage.newHeight+20], 2);
        //this.colorTransformTo(200, 0, 200, 0, 200, 0, 200, 0, 0.3, "linear");
        //this.colorTransformTo(100, 0, 100, 0, 100, 0, 100, 0, 1, "linear", 0.3);
    
}
    
this.onRollOut = function() {
        
//this._parent.click_txt.alphaTo(0, 2);
        
this._parent.click_txt.roundedYSlideTo(-24.61);
        
this._parent.rollover_mc.alphaTo(03);
        
//this.tween(["_width", "_height"], [myImage.newWidth, myImage.newHeight], 2);
    
}

    
this.onRelease = function()  {
        
        
// hide the dropdown if it's open
        
if(dropDown) {
            
doDropDown();
        }
        
        
// reset current image to this image user just clicked on
        
_root.curImage this.curImage;
        
// reset the category
        
_root.curCat this.curCat;
        
        
this._parent.rollover_mc.alphaTo(900.5);
        
//this._parent.viewing_mc.alphaTo(100, 6);

        
this._parent.click_txt.roundedYSlideTo(-24.61);
        
        
//activateItem(this, myImage.newWidth, myImage.newHeight);
        
        
        // view the image in full scale
        
showFullImage(this.imgToLoadthis.imgDesc);
    
    }
}



// TIMER FUNCTION
function loadTimer() {

    var 
speed defTranSpeed;
    
//var timer = _root.attachMovie("timer", "timer_mc", _root.getNextHighestDepth());

    //timer._x = 474;
    //timer._y = 15;

    
myTimer = new Timer();
    
myTimer.setDelay(5);
    
myTimer.setAlarm(speed);
    var 
obj = new Object;
    
myTimer.addListener(obj);
    
    
//reset the timer
    
myTimer.reset();
    
    
obj.onTimerStart = function(t){
        
//trace("Starting countdown::\n" + myTimer.getAlarm());
    
}
    
obj.onTimerTick = function(t){
        
        
//trace(myTimer.getAlarm() - t);
        
var curTime myTimer.getAlarm() - t;
        
//trace(curTime);
        
        
var curScale = -Math.round((((curTime 100)/speed) - 100));
        
timer_mc.bar_mc._xscale curScale;
        
timer_mc.bar_mc._alpha 50;
        
/*
        // caculate degrees relative to seconds
        // caculate 0 to 360

        var curDegree = - Math.round((((curTime * 360)/speed) - 360));
        //reset rotation
        timer.lhalf_mc._rotation = 0;
        if(curDegree < 180) {
            timer.fhalf_mc._rotation = curDegree + 180;
        }
        if(curDegree >= 180) {
            timer.lhalf_mc._rotation = curDegree + 180;
        }
        */
    
}
    
obj.onTimerAlarm = function(){

        
//trace("Time is up!");
        
        //total of images in chosen category
        
var totalImages myGallery[curCat]["image"].length;
        
        
// update the counter and load the news using counter
        
if(curImage == totalImages) { // after last one go back to first image
            
curImage 0;
        }

        if(
curImage totalImages-1) {
            
showNextImage();
        } else {
            
curImage = -1;
            
showNextImage();
        }
        
//trace(curImage);
        
        // reset the timer so it loops
        
myTimer.reset();
    }
    
    
myTimer.start();
    
    
slideshow_mc.onRelease = function() {
        
timerToggle();
    }
}



function 
showFullImage(imgToLoaddesc) { //<--------------------------------------------------------- SHOW FULL IMAGE // START FROM HERE...

    // reset the conditions
    
transBG_mc._x 34;
    
transBG_mc._y 34;
    
transBG_mc._visible true;
    
transBG_mc.alphaTo(1001);
    
transBG_mc.mask_mc._alpha 0;

    
transBG_mc.swapDepths(_root.getNextHighestDepth());
    
transBG_mc.fake_btn.enabled false;

    
transBG_mc.mask_mc.alphaTo(1000.7undefined0
        function() {
            
//load preloader
            
var myPreloader transBG_mc.attachMovie("imagePreloader""preloader_mc"this.getNextHighestDepth());
            
myPreloader._alpha 0;
            
myPreloader.alphaTo(1001);
            
myPreloader._x transBG_mc._width/2;
            
myPreloader._y transBG_mc._height/2-20;
            
lo***ull(imgToLoaddesc);
        }
    );
    
    
/*
    transBG_mc.exit_mc.onRelease = function() {
        transBG_mc.slideTo(34, -900, 0.1);
    }
    */
}

function 
lo***ull(imgToLoaddesc) {

    var 
holder transBG_mc.picBG_mc.empty_mc;
    
    
holder._alpha 0;
    
holder.loadMovie(imageDir+imgToLoad);
    
    var 
temp holder._parent.createEmptyMovieClip("temp"holder._parent.getNextHighestDepth());
    
    
temp.onEnterFrame = function() {
        var 
loaded holder.getBytesLoaded();
        var 
total holder.getBytesTotal();
        var 
perc Math.round((loaded/total)*100);
        
        
//trace(perc);
        
        
if(perc == 100) {
            
// hide the preloader
            
transBG_mc.preloader_mc.alphaTo(01"linear"0, function() { transBG_mc.prealoder_mc.removeMovieClip(); });
            
//trace(holder._width);
            
checkImageWidth(holderdesc);
            
            
delete this.onEnterFrame;
            
temp.removeMovieClip();
        }
    }
}

function 
checkImageWidth(holderdesc) {
    var 
temp holder._parent.createEmptyMovieClip("temp"holder._parent.getNextHighestDepth());
    
temp.onEnterFrame = function() {
        if(
holder._width 0) {
            
//trace(holder._width);
            
displayFullImage(holderdesc);
            
// start the timer
            
if(autoSlide) {
                
loadTimer();
            }
            
delete this.onEnterFrame;
            
temp.removeMovieClip();
        }
    }
}


function 
timerToggle() {
    if(
autoSlide) {
        
slideshow_mc.gotoAndStop(2);
        
myTimer.pause();
        
autoSlide false;
    } else {
        
slideshow_mc.gotoAndStop(3);
        
myTimer.resume();
        
autoSlide true;
    }
}



function 
displayFullImage(imageHolderdesc) {
    

    var 
imageBorder 20;
    var 
mcW imageHolder._width;
    var 
mcH imageHolder._height;
    
    
    
//total of images in chosen category
    
var totalImages myGallery[curCat]["image"].length;
    
curImage_txt.text Number(_root.curImage+1)+" of "+totalImages;

    
enableImageNav(true);

    
//trace(mcW);
    
    
if(mcW 710) {
        
imageHolder.maxWidth 710;
        var 
newSize imageHolder.resizeToFit();
        
imageHolder.tween(["_width""_height"], [newSize.newWidthnewSize.newHeight], 0.5undefined);
        var 
mcW newSize.newWidth;
        var 
mcH newSize.newHeight;
    }
    
    var 
xCenter = (transBG_mc.fake_btn._width/2) - (Number(mcW+imageBorder)/2);
    var 
yCenter = (transBG_mc.fake_btn._height/2) - (Number(mcH+imageBorder)/2);
    
    
// center the image
    
transBG_mc.picBG_mc.slideTo(xCenteryCenter0.5);
    
// resize the background
    
transBG_mc.picBG_mc.bg_mc.tween(["_width""_height"], [mcW+imageBordermcH+imageBorder], 0.5undefined0, function() {  });
    
transBG_mc.picBG_mc.bg_mc.alphaTo(1000.5"linear"0, function() { imageHolder.alphaTo(1002); });

    
    var 
descMC _root.transBG_mc.desc_mc;
    
    
// put description
    
descMC.desc_txt.text desc;
    
    
    
// resize textfield
    
var padding 30;
    var 
myFormat_fmt = new TextFormat();
    var 
textDimension myFormat_fmt.getTextExtent(desc200);
    var 
tWidth textDimension.textFieldWidth;
    var 
tHeight textDimension.textFieldHeight+20// used 20 to prevent it from text get cut off at the end //////////////////////////
    
    
descMC.desc_txt._width tWidth;
    
descMC.desc_txt._height tHeight;
    
// reposition textfield
    
descMC.desc_txt._x padding/2;
    
descMC.desc_txt._y padding/2;
    
descMC.descBG_mc._width tWidth+padding;
    
descMC.descBG_mc._height tHeight+padding;
    
descMC._alpha 0;
    
    
imageHolder.onRollOver = function() {
        
descMC.alphaTo(1001);
    }
    
imageHolder.onRollOut = function() {
        
descMC.alphaTo(01);
    }
    
    
// center image description mc
    
var xDescCenter = ((transBG_mc.fake_btn._width+imageBorder)/2) - ((descMC._width+imageBorder)/2);
    var 
yDescCenter = ((transBG_mc.fake_btn._height+imageBorder)/2) - ((descMC._height+imageBorder)/2);
    
    
descMC.slideTo(xDescCenteryDescCenter0.5);
    
    
// hide full view
    
exit_mc.onRelease = function() {
        var 
DisappearW mcW;
        var 
DisappearH mcH;
        var 
DisappearXCenter = (transBG_mc.fake_btn._width/2) - (Number(DisappearW+imageBorder/2)/2);
        var 
DisappearYCenter = (transBG_mc.fake_btn._height/2) - (Number(DisappearH+imageBorder/2)/2);
        
        
imageHolder.alphaTo(00.2"linear"0, function() { imageHolder.unloadMovie() });
        
//transBG_mc.picBG_mc.slideTo(DisappearXCenter, DisappearYCenter, 0.5, undefined, 0.5);
        //transBG_mc.picBG_mc.bg_mc.tween(["_width", "_height"], [DisappearW, DisappearH], 0.5, undefined, 0.5);
        
transBG_mc.picBG_mc.bg_mc.alphaTo(00.5"linear"undefined);
        
transBG_mc.alphaTo(00.5"linear"undefined, function() { transBG_mc._visible false;});
        
        
        
// disable image nav 
        
enableImageNav(false);
        
        
this.btnRollOut();
        
        
// stop the timer
        
myTimer.pause();
    
    }
    
exit_mc.onRollOver = function() {
        
this.btnRollOver();
    }
    
exit_mc.onRollOut = function() {
        
this.btnRollOut();
    }
    
    
next_mc.onRelease = function() {
        
// turn off timer only if autoSlide is true
        
if(autoSlide) {
            
timerToggle();
        }
        
showNextImage(imageHolder);
    }
    
next_mc.onRollOver = function() {
        
this.btnRollOver();
    }
    
next_mc.onRollOut = function() {
        
this.btnRollOut();
    }
    
    
prev_mc.onRelease = function() {
        
// turn off timer only if autoSlide is true
        
if(autoSlide) {
            
timerToggle();
        }
        
showPrevImage(imageHolder);
    }
    
prev_mc.onRollOver = function() {
        
this.btnRollOver();
    }
    
prev_mc.onRollOut = function() {
        
this.btnRollOut();
    }
    
    
slideshow_mc.onRelease = function() {
        
timerToggle();
    }
    
slideshow_mc.onRollOver = function() {
        if(!
autoSlide) {
            
this.btnRollOver();
        }
    }
    
slideshow_mc.onRollOut = function() {
        
this.btnRollOut();
    }
    
}




MovieClip.prototype.btnRollOver = function() {
    
this.btn_mc.bg_mc.colorTo(0x3333330.1);
    
this.btn_mc.icon_mc.colorTo(0xffffff0.1);
}

MovieClip.prototype.btnRollOut = function() {
    
this.btn_mc.bg_mc.colorTo(0xffffff0.1);
    
this.btn_mc.icon_mc.colorTo(0x3333330.1);
}




// enable image navigation buttons
function enableImageNav(showNav) {
    if(
showNav) {
        if(
autoSlide) {
            
slideshow_mc.gotoAndStop(3);
        } else {
            
slideshow_mc.gotoAndStop(2);
        } 
        
next_mc.gotoAndStop(2);
        
prev_mc.gotoAndStop(2);
        
exit_mc.gotoAndStop(2);
        
curImage_txt.colorTo(0x3333330.5);
        
slideshow_mc.enabled true;
        
next_mc.enabled true;
        
prev_mc.enabled true;
        
exit_mc.enabled true;
        
    } else {
        
slideshow_mc.gotoAndStop(1);
        
next_mc.gotoAndStop(1);
        
prev_mc.gotoAndStop(1);
        
exit_mc.gotoAndStop(1);
        
curImage_txt.colorTo(0xcccccc0.5);
        
slideshow_mc.enabled false;
        
next_mc.enabled false;
        
prev_mc.enabled false;
        
exit_mc.enabled false;
    }
}

function 
showNextImage(imageHolder) {
    
//total of images in chosen category
    
var totalImages myGallery[curCat]["image"].length;
    if(
totalImages-curImage) {
        
        
_root.curImage += 1;

    } else if(
totalImages-== curImage) {
        
        
_root.curImage 0;
        
    }
    
    
//fade the picture out
    
imageHolder.alphaTo(00.5"linear");

    var 
ImgDesc myGallery[curCat]["image"][curImage]["desc"];
    var 
ImgFull myGallery[curCat]["image"][curImage]["img"];
    
    
/*
    // disable thumb
    var thumb = imgWrap_mc["thumb_mc"+curImage];
    activateItem(thumb);*/
    
    
curImage_txt.text Number(_root.curImage+1)+" of "+totalImages;
    
showFullImage(ImgFullImgDesc);
    
}


function 
showPrevImage(imageHolder) {
    
//total of images in chosen category
    
var totalImages myGallery[curCat]["image"].length;
    if(
curImage 0) {
        
        
_root.curImage -= 1;

    } else if(
curImage == 0) {
        
        
_root.curImage totalImages-1;
        
    }
    
    
//fade the picture out
    
imageHolder.alphaTo(00.5"linear");
    var 
ImgDesc myGallery[curCat]["image"][curImage]["desc"];
    var 
ImgFull myGallery[curCat]["image"][curImage]["img"];
        
    
curImage_txt.text Number(_root.curImage+1)+" of "+totalImages;
    
showFullImage(ImgFullImgDesc);
    
}


function 
activateItem(itemoWidthoHeight) {
    
// hide the dropdown if it's open
    
if(dropDown) {
        
doDropDown();
    }
    
    if (
currentItem != false) {
        
deactivateItem();
    }
    
currentItem item;

    
currentItem.oWidth oWidth;
    
currentItem.oHeight oHeight;
    
currentItem.enabled false;
}
 
function 
deactivateItem() {
    
currentItem.tween(["_width""_height"], [currentItem.oWidthcurrentItem.oHeight], 2);
    
currentItem._parent.viewing_mc.alphaTo(01);
    
currentItem._parent.rollover_mc.alphaTo(03);
    
currentItem.enabled true;
    
currentItem undefined;
}

/* prototype for resizing an image to defined size while keeping ratio */
/* it returns an object with new width and height */

MovieClip.prototype.resizeToFit = function (){

    var 
pMaxWidth this.maxWidth;
    var 
pMaxHeight this.maxHeight;
    
    
// determines ratio depends on the width and height
    //this._width>=this._height ? ratio=pMaxWidth/this._width : ratio=pMaxHeight/this._height;
    
    // ratio based on width
    
var ratio=pMaxWidth/this._width;

    var 
resizedImg = new Object();
    
resizedImg.newWidth Math.round(this._width*ratio);
    
resizedImg.newHeight Math.round(this._height*ratio);
    
    return 
resizedImg;
}


function 
showTnView(catNumtotalImg) {
    
viewMode "thumbView";
    
curCat catNum;
    
    
    
// determine the number of pages needed for viewing thumbnails
    
if(totalImg numThumbDisplay) {
        
trace('true');
        
thumbNumPages Math.ceil(totalImg/numThumbDisplay);
        
    } else {
        
trace('false');
        
// if categories are less than the limit only one page is needed
        
thumbNumPages 1;
    }

    
// start from first page
    
thumbPageCounter 1;
            
    
// start from 0;
    
var pos 0;
    
    
// output page status
    
page_txt.text thumbPageCounter+" of "+thumbNumPages;
    
    
// initialize
    
prevBtn(thumbPageCounter);
    
nextBtn(thumbPageCounterthumbNumPages);
    
    
remove();
    
showThumbs(catNumpos);
    
}
    
function 
remove() {

    
hideCat();
    
/*
    // count how many thumbnails are currently sitting inside of imgWrap_mc
    var count = 0;
    for(var each in imgWrap_mc) {
        count++;
    }
    trace(count);
    
    var i=0;
    var temp = _root.createEmptyMovieClip("temp", _root.getNextHighestDepth());
    temp.onEnterFrame = function(){
        if(i<count){
            imgWrap_mc["thumb_mc"+i].tnHider_mc.alphaTo(100, 1, undefined, 0, function() { this._parent.removeMovieClip() });
            //catWrap_mc["cat_mc"+i].alphaTo(0, 1, undefined, 0, function() { });
            //imgWrap_mc["thumb_mc"+i].alphaTo(0, 1, undefined, 0, function() { this.removeMovieClip() });
            
            i++
        } else {
            hideCat();
            delete this.onEnterFrame;
        }
    }
    */
}


function 
hideCat() {
    for(var 
i=0i<catTotali++) {
        var 
eachCat catWrap_mc["cat_mc"+i];
        
        
//eachCat.tween("_x", 0, 1);
        //eachCat.tween("_y", Math.round(Number(eachCat._height+1) *i), 1);
        
eachCat._visible false;
    }
}


function 
showThumbs(catNumpos) {
    
    
imgWrap_mc.removeMovieClip();
    var 
imgWrap _root.createEmptyMovieClip("imgWrap_mc"_root.getNextHighestDepth());

    
imgWrap._x 58;
    
imgWrap._y 120;
    
    
dropDown_mc.swapDepths(_root.getNextHighestDepth());
    
dropDownBtn_mc.swapDepths(_root.getNextHighestDepth());
    
    var 
total;

    var 
totalThumbs myGallery[catNum]["image"].length;

    var 
numRows totalThumbs/catCol;
    
    var 
xnum catCol;
    var 
ynum numRows;

    var 
xgap catColXgap;
    var 
ygap catColYgap-28;
    var 
ox 0
    
var oy 0
    
    
var total xnum*ynum
    
    
var i=pos;
    var 
j=0// used to reset the position

    
var taco i+numThumbDisplay;
    
    var 
temp _root.createEmptyMovieClip("temp"_root.getNextHighestDepth());
    
temp.onEnterFrame = function(){
        
        if(
i<taco && i<totalThumbs){
            
//trace(i);
            
var myImg imgWrap_mc.attachMovie("thumb""thumb_mc"+ii);
            
            
myImg._alpha 0;
            
myImg.alphaTo(1003);
            
myImg.tnHider_mc.alphaTo(03);

            
myImg._x Math.round(ox + (j%xnum)*(xgap myImg._width-4)); // subtract 9 : because of drop shadow it adds to the width of box
            
myImg._y Math.round(oy int(j/xnum)*ygap);

            var 
ImgDate myGallery[catNum]["image"][i]["date"];
            var 
ImgTitle myGallery[catNum]["image"][i]["title"];
            var 
ImgDesc myGallery[catNum]["image"][i]["desc"];
            var 
ImgThumb myGallery[catNum]["image"][i]["thumb"];
            var 
ImgFull myGallery[catNum]["image"][i]["img"];
            
            
myImg.title_txt.text =  ImgTitle;
            
myImg.date_txt.text =  ImgDate;
            
            
myImg.empty_mc.curCat catNum;
            
myImg.empty_mc.curImage i;
            
myImg.empty_mc.imgDesc ImgDesc;
            
myImg.empty_mc.imgToLoad ImgFull;
            
myImg.empty_mc.thumbToLoad ImgThumb;
            
myImg.empty_mc.loadThumb();
        
            
j++;
            
i++;
        } else {
            
delete this.onEnterFrame;
            
this.removeMovieClip();
        }
    }
// end of showThumbs()
    



dropDownBtn_mc.onRelease = function() {
    
doDropDown();
}


function 
doDropDown() {
    if(!
dropDown) {
        
dropDown_mc.ySlideTo(680.8"easeOutExpo");
        
dropDown true;
    } else {
        
dropDown_mc.ySlideTo(-1200.8"easeOutExpo");
        
dropDown false;
    }
}

dropDown_mc.mask_mc.onEnterFrame = function() {
    
    
//only if btns exceed
    
if(dropDown_mc.bg_mc.hitTest(_root._xmouse_root._ymousetrue) && this._parent.catBtn_mc._height this._height) {
        
ymin this._y+this._height-this._parent.catBtn_mc._height;
        
ymax this._y;
        
conv = (this._ymouse-15)*1.3/this._height;
        
conv>conv=null;
        
conv<conv=null;
        
this._parent.catBtn_mc.ySlideTo(Math.round(ymax conv*(ymax-ymin)), 1); 
    }
}

dropDown_mc._y = -120;
dropDown_mc.catBtn_mc.setMask(dropDown_mc.mask_mc);
dropDown_mc.setMask(dropMask_mc); 


codigo php

Código PHP:
<?php 
header
("Content-type: text/xml; charset=utf-8"); 
include_once(
'../db/dbmanager.php');


          
$con = new dbmanager;
          
//usamos el método conectar para realizar la conexion
          
           
if($con->conexion()== true)
           {
               echo
"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
               echo 
'<gallery title="Indusupply S.A" thumbDir="img/thumbs/" imageDir="img/" random="true">';
                
                    
//--------------------------------------------------------------------------
                    // hacer una consulta  para saber cuantas y cuales galerias son 
                    //--------------------------------------------------------------------------
                    
$registroGallery ="SELECT idCategoria,descripcion FROM categoria ORDER BY idCategoria ASC";
                    
$resultmysql_query($registroGallery) or die (mysql_error());
                    
$totalGallery mysql_num_rows($result); // total de categoria que me genero la consulta (ejemplo )
                    
                    
                    //--------------------------------------------------------------------------
                    // primer ciclo de repeticion para mostrar todas las categorias de galeria
                    //--------------------------------------------------------------------------
                
                    
for($cantGallery=0;$cantGallery $totalGallery$cantGallery++)
                    {
                    
$row mysql_fetch_array($result);
                    
$categoria $row['descripcion'];
                    
$idcat $row['idCategoria'];
                    
$imageCategoria mysql_query("SELECT category,date, title,descri, thumb, img FROM galeria where category ='".$idcat."'") or die (mysql_error());
                    
$totalImages mysql_num_rows($imageCategoria) ; // total de datos por categoria que me genero la consulta
                    
                  
                    //------------------------------------------------------------------------
                    // -----------NODO DE APERTURA DE LAS CATEGORIAS -------------------------
                    //------------------------------------------------------------------------
                     
echo  '<category name="'.$categoria.'">';  
                  
                    
//--------------------------------------------------------------------------
                    //-------- SEGUNDO CICLO DE REPETICIÓN PARA MOSTRAR IMAGENE SPOR CATEGORIA 
                    //--------------------------------------------------------------------------
                  
                    
for($cantImages=0;$cantImages<$totalImages;$cantImages++)
                    {
$datos mysql_fetch_array($imageCategoria);
                            
//------------------------------------------------------------------------
                            //------------- nodo de apretura de las imagenes ----------------------
                            //------------------------------------------------------------------------
                            
echo "<image>";
                                echo 
"<date>".$datos['date']."</date>";
                                echo 
"<title>".$datos['title']."</title>";
                                echo 
"<desc>".$datos['descri']."</desc>";
                                echo 
"<thumb>".$datos['thumb']."</thumb>";
                                echo 
"<img>".$datos['img']."</img>";
                            echo 
"</image>";
                    }
//----------------------cierre del primer ciclo de repetición
                   
                    //------------------------------------------------------------------------
                    // -----------NODO DE cierre DE LAS CATEGORIAS -------------------------
                    //------------------------------------------------------------------------
                    
echo "</category>";
                   
                    } 
//----------------------cierre del segundo ciclo de repetición
                
                    
echo "</gallery>";
                    
                      if(!
$result)
                      {
                       return 
false;   
                      }
                      else
                      {
                        return  
$result;
                      }
}
?>

Espero que sea de su agrado

"El hombre es esclavo de sus palabras y dueño de su silencio"

"No hay nada más bello que vivir"... R.I.P. Jaime Moreno Garcia

Última edición por sasuke.17; 17-nov-2010 a las 17:54
Responder Citando
Los siguientes 2 usuarios agradecen a sasuke.17 por este mensaje:
Felina05 (17-nov-2010), jchierro (17-nov-2010)
 


(0 miembros y 1 visitantes)
 

Normas de Publicación
No puedes crear nuevos temas
No puedes responder mensajes
No puedes subir archivos adjuntos
No puedes editar tus mensajes

Los Códigos BB están Activado
Las Caritas están Activado
[IMG] está Activado
El Código HTML está Desactivado

Ir al Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Montaje de un Ordenador desde Cero [Tutorial] jchierro Tutoriales & Videos Tutoriales 5 17-ene-2016 20:20
PLACA BASE: Componentes y sus funciones Eloy58 PC's Desktops 45 28-sep-2013 13:25
Impresionante y Revolucionario Soporte nativo sobre discos VHD en Windows7 Sabid Barahona Windows Vista & 7 4 25-dic-2011 20:38
Feliz navidad - 1º Concurso de Postales Navideñas de IV - Premio Cuenta PREMIUM Eloy58 Eventos y Concursos 53 31-dic-2009 20:33


Desarrollado por: vBulletin® Versión 3.8.1
Derechos de Autor ©2000 - 2025, Jelsoft Enterprises Ltd.
Ad Management by RedTyger