eu tenho um código de ActionScript, mas num entendo ele!
gostaria que alguém me explicasse ele passo a passo, porque queria customizar a galeria do meu jeito!
obs: as partes que eu entendi eu puis em comentário
O AS é esse:
//Carregar fonte
var fonte:TextFormat = new TextFormat();
fonte.font = 'Hobo Std';
fonte.size = 35;
txt_dinamico.embedFonts = true;
txt_dinamico.setTextFormat(fonte);
/* -----------------------------------------------------------------
all design and code copyright (c) www.lukamaras.com
----------------------------------------------------------------- */
/* -------------------- Criando as Variaveis -------------------- */
var menuSpeed:Number = 6;//velociade do menu
var btnNext:Button = next_btn;//Export do botão
var btnPrev:Button = prev_btn;//Export do botão
var menuDown:Button = menuDown_btn;//intancia do botao Down
var menuUp:Button = menuUp_btn;//intancia do botao UP
menuUp._alpha = 0;//btn UP invisible
menuUp.enabled = false;//e desabilitato
var firstLook:Boolean = true;
var menuButtons:MovieClip = galleryMenu_mc.buttonsHolder_mc;//caminho de intancia do mc. dos botoes do menu
var galleryMask:MovieClip = galleryMenu_mc.galleryMask_mc;//caminho de instancia do mc. mascara dos botoes do menu
galleryMask._height = 340;//altura da mascara dos botoes
var imagesHolder:MovieClip = imagesHolder_mc;//instacia de onde ira abrir as imagens
var descText:TextField = desc_txt;//testo de descrição
var imagesInGallery:Array = new Array();//variavel que cria uma nova referencia vazia
var galleryNames:Array = new Array();
var galleryIntros:Array = new Array();
var descriptions:Array = new Array();
var tracker:Number = new Number();//variavel de novo numero
var whatIsLoading:String = new String();//varial de novo texto
var galleryBtnLeftMargin:Number = 10;//botoes do menu com margem esquerda 10
var galleryBtnUpperMargin:Number = 60;//botoes do menu com margem superior 60
var galleryBtnVSpace:Number = 23;//espaço entre os textos dos botoes do menu
var thumbMarginX:Number = 96;//margem entre mcs. pequenos em X
var thumbMarginY:Number = 68;//margem entre mcs. pequenos em Y
/* -------------------- Alinhando e posicionando o mc. imagesHolder_mc, o logo e a campo de texto da descrição -------------------- */
imagesHolder._x = 243;//variavel que diz a posição em X do mc imagesHolder_mc
imagesHolder._y = galleryBtnUpperMargin;//diz que a posição em Y do mc imagesHolder_mc vai ser igual o numero da outra variavel (60)
logo_mc._x = logo_mc._y=galleryBtnLeftMargin;
desc_txt._x = 243;//posição do campo de texto em X
desc_txt._y = 330;//posição do campo de texto em Y
/* -------------------- O que estará escrito no campo de texto -------------------- */
descText.text = "Click on a gallery name 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 galleries to scroll through them.";
/* -------------------- importando as definições do DropShadow -------------------- */
import flash.filters.DropShadowFilter;
var shadowEffect:DropShadowFilter = new DropShadowFilter(3, 45, 0x000000, 100, 3, 3, 1, 3);
var thumbsFilter:Array = [shadowEffect];
/* -------------------- MovieClipLoader & Listener -------------------- */
var loader:MovieClipLoader = new MovieClipLoader();//variavel para carregar mcs.
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+"%";
}
};
/* -------------------- loading XML -------------------- */
var fotoAtual = 0;
var imageGallery:XML = new XML();//variavel para carregar novo XML
imageGallery.ignoreWhite = true;//ignora os espaço em branco do XMLq
imageGallery.onLoad = function(success) {
if (success) {
parseGalleries();
//-----------------------botão next e prev.---------------------------------
btnNext.onPress = function() {
if (fotoAtual<total-1) {
++fotoAtual;
thumbClickable(fotoAtual);
}
// end if
};
btnPrev.onPress = function() {
if (fotoAtual>0) {
--fotoAtual;
thumbClickable(fotoAtual);
}
// end if
};
};
};
imageGallery.load("gallery/gallery.xml");
/* -------------------- acahndo o texto no XML -------------------- */
function parseGalleries():Void {
if (imageGallery.firstChild.nodeName == "galleries") {
var rootNode:XMLNode = imageGallery.firstChild;
for (i=0; i<rootNode.childNodes.length; i++) {
if (rootNode.childNodes[i].nodeName == "gallery") {
currentGallery = rootNode.childNodes[i];
imagesInGallery.push(currentGallery.childNodes.length);
galleryNames.push(currentGallery.attributes.title);
galleryIntros.push(currentGallery.attributes.intro);
currentGalleryTitle = rootNode.childNodes[i].attributes.title;
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 = "0"+(i+1)+" "+currentGalleryTitle.toUpperCase();
for (j=0; j<currentGallery.childNodes.length; j++) {
if (currentGallery.childNodes[j].nodeName == "image") {
currentDescription = currentGallery.childNodes[j].firstChild.toString();
descriptions.push(currentDescription);
}
}
}
}
}
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 {
next_btn._visible = false;
prev_btn._visible = false;
removeMovieClip(thumbsDisplayer);
removeMovieClip(displayBigImage);
tracker = 0;
thumbsDisplayer = imagesHolder.createEmptyMovieClip("thumbsDisplayer_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 = "gallery/"+whichGallery+"/thumbs/"+thumbNumber+".jpg";
whatIsLoading = "thumb";
loader.loadClip(thumbPath, target);
}
function thumbClickable():Void {
currentThumbnail.onPress = function() {
_root.attachMovie("next_btn", "next_btn", _root.getNextHighestDepth());
next_btn._x = 714;
next_btn._y=176,5;
next_btn._visible = true;
prev_btn._visible = true;
_root.attachMovie("prev_btn", "prev_btn", _root.getNextHighestDepth());
prev_btn._x = 248;
prev_btn._y=176,5;
bigNumber = this._name.substr(9);
displayBigImage = imagesHolder.attachMovie("big image holder", "bigImage_mc", imagesHolder.getNextHighestDepth());
target = displayBigImage.imageHolder_mc;
bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
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() {
next_btn._visible = false;
prev_btn._visible = false;
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.8)) {
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.8)) {
menuButtons._y = Math.round(targetPos);
delete menuButtons.onEnterFrame;
menuDown.enabled = true;
menuUp.enabled = true;
}
};
}
};
}
Pergunta
AdriKR
eu queria fazer uma galeria igual a desse site: http://www.miguelbemfica.com.br/home/.
eu tenho um código de ActionScript, mas num entendo ele!
gostaria que alguém me explicasse ele passo a passo, porque queria customizar a galeria do meu jeito!
obs: as partes que eu entendi eu puis em comentário
O AS é esse:
Link para o comentário
Compartilhar em outros sites
0 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.