Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Olá!
Estou trabalhando numa galeria de imagens que e uma mistura da Polaroid com a de várias categorias do Flashden.
Aqui estão os arquivos-chave: http://rodrigokurtz.com/galeria/galeria.rar
E esse seria o swf: http://rodrigokurtz.com/galeria/galeria.swf
O que acontece:
1) O flash recebe os dados do xml que é montado da seguinte maneira:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<content>
<gallery Name="Tim Burton" Folder="fotos1">
<image url="fotos1/foto1.jpg" desc="Tim 1"/>
<image url="fotos1/foto2.jpg" desc="Tim 2"/>
<image url="fotos1/foto3.jpg" desc="Tim 3"/>
<image url="fotos1/foto4.jpg" desc="Tim 4"/>
<image url="fotos1/foto5.jpg" desc="Tim 5"/>
<image url="fotos1/foto6.jpg" desc="Tim 6"/>
<image url="fotos1/foto7.jpg" desc="Tim 7"/>
</gallery>
<gallery Name="Annie Leibovitz" Folder="fotos2">
<image url="fotos2/foto1.jpg" desc="Anne 1"/>
<image url="fotos2/foto2.jpg" desc="Anne 2"/>
<image url="fotos2/foto3.jpg" desc="Anne 3"/>
<image url="fotos2/foto4.jpg" desc="Anne 4"/>
<image url="fotos2/foto5.jpg" desc="Anne 5"/>
</gallery>
<gallery Name="Calma" Folder="fotos2">
<image url="fotos2/foto1.jpg" desc="Calma 1"/>
<image url="fotos2/foto2.jpg" desc="Calma 2"/>
<image url="fotos2/foto3.jpg" desc="Calma 3"/>
<image url="fotos2/foto4.jpg" desc="Calma 4"/>
</gallery>
</content>
2) Ele transforma os Names em links, organiza os botões e carrega a primeira galeria de imagens. O código AS é o seguinte:
// Importa
import flash.filters.*;
import flash.display.BitmapData;
//////////////// Variáveis iniciais /////////////////////////////////////////////////////////////////////////////////
_global.galleryNum = 0;
_global.ID = 0;
select_mcY = select_mc._y;
var photoHolder = new Array();
var skalerTempo = 3;
var thumbStr = 10;
var fotoSkygge:DropShadowFilter = new DropShadowFilter(0, 45, 0x333333, 0.8, 10, 10, 2, 3);
var glow:GlowFilter = new GlowFilter(0x333333,100,150,150,1.5,3,true,true);
var bakgrunnPattern:BitmapData = BitmapData.loadBitmap("bakgrunn");
loadID = function () {
byggBilder()
};
//////////////// Construindo o Select galeria //////////////////////////////////////////////////////////////////////
buildGallery = function () {
// Reseta a galeria
for (i=0;i < photoHolder.length;i++) {
removeMovieClip(_root["fotoHolder"+i]);
removeMovieClip(_root["fotoHolder"+i++]);
removeMovieClip(_root["fotoHolder"+1]);
removeMovieClip(_root["fotoHolder"+2]);
removeMovieClip(_root["fotoHolder"+3]);
removeMovieClip(_root["fotoHolder"+4]);
removeMovieClip(_root["fotoHolder"+5]);
removeMovieClip(_root["fotoHolder"+6]);
removeMovieClip(_root["fotoHolder"+7]);
removeMovieClip(_root["fotoHolder"+8]);
removeMovieClip(_root["fotoHolder"+9]);
removeMovieClip(_root["fotoHolder"+10]);
removeMovieClip(_root["fotoHolder"+11]);
removeMovieClip(_root["fotoHolder"+12]);
removeMovieClip(_root["fotoHolder"+13]);
removeMovieClip(_root["fotoHolder"+14]);
removeMovieClip(_root["fotoHolder"+15]);
removeMovieClip(_root["fotoHolder"+16]);
removeMovieClip(_root["fotoHolder"+17]);
removeMovieClip(_root["fotoHolder"+18]);
removeMovieClip(_root["fotoHolder"+19]);
removeMovieClip(_root["fotoHolder"+20]);
};
total = xmlNode.childNodes[_global.galleryNum].childNodes.length;
galleryTotal = xmlNode.childNodes.length;
// Cria Botão Select
for (n=0; n<galleryTotal; n++) {
Name[n] = xmlNode.childNodes[n].attributes.Name;
Folder = xmlNode.childNodes[_global.galleryNum].attributes.Folder;
select_mc.selectBttn_mc.selectBttn.duplicateMovieClip("selectBttn"+n, n);
select_mc.selectBttn_mc["selectBttn"+n]._y = -select_mc.selectBttn_mc.selectBttn._height-(select_mc.selectBttn_mc.selectBttn._height)*n;
select_mc.selectBttn_mc["selectBttn"+n].txt_mc.txt.text = Name[n];
select_mc.selectBttn_mc["selectBttn"+n].ID = n;
}
currentTotal = total;
byggBilder();
};
nome_galeria.html = true;
// Constrói Polaróides
function byggBilder() {
for (i=0;i < photoHolder.length;i++) {
mc = _root.attachMovie("fotoHolder","fotoHolder"+i,_root.getNextHighestDepth(),{_xscale:thumbStr, _yscale:thumbStr,_rotation:30 - 60*Math.random()});
mc.txt.text = photoHolder[i].desc;
if (Math.round(Math.random()*1) == 1) {
// tilfeldig y akse
mc._y = (Stage.height*Math.random())+(mc._height*2);
if (Math.round(Math.random()*1) == 1) mc._x = Stage.width+(mc._width*2);
else mc._x = -(mc._width*2);
}
else {
// tilfeldig x akse
mc._x = (Stage.width*Math.random())+(mc._width*2);
if (Math.round(Math.random()*1) == 1) mc._y = Stage.height+(mc._height*2);
else mc._y = -(mc._height*2);
}
mc.newX = Math.round((mc._width/2) + (Stage.width-mc._width)*Math.random());
mc.newY = Math.round((mc._height/2) + (Stage.height-mc._height)*Math.random());
mc.oldRotation = mc._rotation;
mc.oldX = mc.newX;
mc.oldY = mc.newY;
mc.startX = mc._x;
mc.startY = mc._y;
mc.oldHeight = mc._yscale;
mc.oldWidth = mc._xscale;
mc.id = i;
mc.onEnterFrame = fotoAnimer;
mc.filters = [fotoSkygge];
mc.dragPol.onPress = drag;
mc.dragPol.onReleaseOutside = mc.dragPol.onRelease = stopdrag;
photoHolder[i].mc = mc;
lastBilde(mc,photoHolder[i].url);
delete mc;
}
antallBilder = i;
}
function lastBilde(mc, url) {
mc.createEmptyMovieClip("tmp",mc.getNextHighestDepth());
lastBildeH.loadClip(url, (flickrID) ? mc.bildeHolder:mc.tmp);
}
var lastBildeH:MovieClipLoader = new MovieClipLoader();
var lastBildeHL:Object = new Object();
lastBildeHL.onLoadStart = function(mc:MovieClip):Void {
mc._parent.attachMovie('preLoader','preloader',mc._parent.getNextHighestDepth());
loaderFarge = new Color(mc._parent.preloader);
mc._parent.preloader.loadtxt.text = "";
loaderFarge.setRGB(0xFFFFFF);
mc._parent.preloader._y = -10;
mc._visible = false;
}
lastBildeHL.onLoadProgress = function(mc:MovieClip, numBytesLoaded:Number, numBytesTotal:Number):Void {
var numPercentLoaded:Number = numBytesLoaded / numBytesTotal * 100;
mc._parent.preloader.percent._width = numPercentLoaded;
}
lastBildeHL.onLoadInit = function(mc:MovieClip) {
mc._parent.preloader.removeMovieClip();
var mc2 = mc._parent.bildeHolder;
if (!flickrID) {
var myBitmap = new BitmapData(mc._width, mc._height,true,0xFFFFFF);
myBitmap.draw(mc);
mc._parent.bildeHolder.attachBitmap(myBitmap, mc._parent.bildeHolder.getNextHighestDepth(), "auto", true);
mc.removeMovieClip();
}
/////
// scale and place image
////
var wP = 468/mc2._width;
var hP = 450/mc2._height;
mc2._width *= (wP < hP) ? hP:wP;
mc2._height *= (wP < hP) ? hP:wP;
mc2._x += -((mc2._width-468)/2);
mc2._y += -((mc2._height-450)/2);
mc2._visible = true;
}
lastBildeH.addListener(lastBildeHL);
// </bygg polaroids>////////////////////////////////
// <hjelpeboks>
_root.attachMovie("help","help",_root.getNextHighestDepth());
help._x = 42;
help._y = 48;
help.filters = [fotoSkygge];
// </hjelpeboks>function rensFilm() {
for (i=0;i<antallBilder;i++) {
mc = eval("fotoHolder"+i);
mc.oldY = mc.startY;
mc.oldX = mc.startX;
mc.onEnterFrame = fotoAnimerTilbake;
removeMovieClip(navigering);
}
}
function fotoAnimer() {
this._y += (this.newY-this._y)/skalerTempo;
this._x += (this.newX-this._x)/skalerTempo;
if (Math.round(this._y) == this.newY) delete this.onEnterFrame;
}
function fotoAnimerTilbake() {
this._y += (this.oldY-this._y)/skalerTempo;
this._x += (this.oldX-this._x)/skalerTempo;
this._xscale += (this.oldWidth-this._xscale)/skalerTempo;
this._yscale += (this.oldHeight-this._yscale)/skalerTempo;
this._rotation += (this.oldRotation-this._rotation)/skalerTempo;
this.nesteKnapp._alpha += (0-this.nesteKnapp._alpha)/skalerTempo;
this.forrigeKnapp._alpha += (0-this.forrigeKnapp._alpha)/skalerTempo;
if ((Math.round(this._y) == this.oldY) && (Math.round(this._x) == this.oldX)) {
delete this.nesteKnapp.onRelease;
delete this.forrigeKnapp.onRelease;
delete this.onEnterFrame;
}
}
function fotoSkaler() {
this._xscale += (100-this._xscale)/skalerTempo;
this._yscale += (100-this._yscale)/skalerTempo;
this._rotation += (this.newRotation-this._rotation)/skalerTempo;
this._x += ((Stage.width/2)-this._x)/skalerTempo;
this._y += ((Stage.height/2)-this._y)/skalerTempo;
this.nesteKnapp._alpha += (60-this.nesteKnapp._alpha)/skalerTempo;
this.forrigeKnapp._alpha += (60-this.forrigeKnapp._alpha)/skalerTempo;
if (Math.round(this._width) == this.newWidth) {
delete this.onEnterFrame;
}
}
function drag() {
if ((fotoSomBlirVist != this._parent) && (!this._parent.onEnterFrame)) this._parent.startDrag();
if (!this.click) {
this.click = true;
this.timer = getTimer()/1000;
}
else {
this.timer2 = getTimer()/1000;
if ((this.timer2-this.timer)<.25) {
visFoto(this._parent);
}
else {
this.timer = getTimer()/1000;
this.click = true;
}
}
this._parent.swapDepths(_root.getNextHighestDepth());
if (fotoSomBlirVist) fotoSomBlirVist.swapDepths(_root.getNextHighestDepth());
}
function stopdrag() {
mc = this._parent;
mc.stopDrag();
if ((fotoSomBlirVist != mc) && (!mc.onEnterFrame)) {
mc.oldX = Math.round(mc._x);
mc.oldY = Math.round(mc._y);
}
}
function visFoto(mc:MovieClip) {
if (fotoSomBlirVist == mc) {
fotoSomBlirVist.onEnterFrame = fotoAnimerTilbake;
delete fotoSomBlirVist;
}
else {
fotoSomBlirVist.onEnterFrame = fotoAnimerTilbake;
mc.newRotation = 0;
mc.oldRotation = mc._rotation;
mc.nesteKnapp.onRelease = function() { visNeste(); }
mc.forrigeKnapp.onRelease = function() { visForrige(); }
mc.onEnterFrame = fotoSkaler;
fotoSomBlirVist = mc;
}
if (fotoSomBlirVist) fotoSomBlirVist.swapDepths(_root.getNextHighestDepth());
}
function visNeste() {
var nb = 0;
if (fotoSomBlirVist) {
nb = fotoSomBlirVist.id +1;
if (nb == antallBilder) nb = 0;
}
visFoto(eval("fotoHolder"+nb));
}
function visForrige() {
var fb = 0;
if (fotoSomBlirVist) {
fb = fotoSomBlirVist.id -1;
if (fb < 0) fb = antallBilder-1;
}
visFoto(eval("fotoHolder"+fb));
}
var stageL:Object = new Object();
stageL.onResize = function() {
for (i=0;i<antallBilder;i++) {
mc = eval("fotoHolder"+i);
if (mc != fotoSomBlirVist) {
mc._x = Math.round(Stage.width * (mc._x/stageWidth));
mc._y = Math.round(Stage.height * (mc._y/stageHeight));
}
else {
fotoSomBlirVist._x = Stage.width/2;
fotoSomBlirVist._y = Stage.height/2;
}
mc.oldX = Math.round(Stage.width * (mc.oldX/stageWidth));
mc.oldY = Math.round(Stage.height * (mc.oldY/stageHeight));
mc.newX = Math.round(Stage.width * (mc.newX/stageWidth));
mc.newY = Math.round(Stage.height * (mc.newY/stageHeight));
mc.startX = Math.round(Stage.width * (mc.startX/stageWidth));
mc.startY = Math.round(Stage.height * (mc.startY/stageHeight));
}
stageWidth = Stage.width;
stageHeight = Stage.height;
fillBG();
fyllGlow();
}
Stage.addListener(stageL);
////////////////////////////////
// <bakgrunn>
function fillBG() {
with (bakgrunsHolder) {
clear();
beginBitmapFill(bakgrunnPattern);
moveTo(0,0);
lineTo(Stage.width,0);
lineTo(Stage.width,Stage.height);
lineTo(0,Stage.height);
lineTo(0,0);
endFill();
}
}
function fyllGlow() {
with (sideGlow) {
clear();
filters = [glow];
beginFill(0xFFFFFF);
moveTo(0, 0);
lineTo(Stage.width, 0);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
lineTo(0, 0);
endFill();
}
}
fillBG();
fyllGlow();
// </bakgrunn>//////////////// LOAD XML DATA //////////////////////////////////////////////////////////////////////
loadXML = function (loaded) {
if (loaded) {
var loop = xmlData.firstChild.childNodes[_global.galleryNum].childNodes;
var num = 0;
if (flickrID) {
for (var i = 0;i < loop.length;i++) {
if (loop[i].nodeName == "item") {
photoHolder[num] = new Array();
num++;
}
}
}
else {
for (i=0;i < loop.length;i++) {
photoHolder[i] = loop[i].attributes;
}
}
xmlNode = this.firstChild;
Name = [];
Folder = [];
Foto = [];
select_mc.selectShow.txt_mc.txt.text = xmlNode.childNodes[_global.galleryNum].attributes.Name;
nomegaleria.txt.text = xmlNode.childNodes[_global.galleryNum].attributes.Name;
buildGallery();
} else {
trace("Error loading XML");
}
};
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("galerias.xml");
E o cógigo interno do botão de selecionar:
on (press) {
_parent._visible = false;
_parent._parent.selectShow.txt_mc.txt.text = this.txt_mc.txt.text;
_global.galleryNum = this.ID;
_parent._parent._parent.buildGallery();
} gotoAndPlay('rollOver');
} gotoAndPlay('rollOut');
}
3)E é aí que complica. Quando seleciono o botão que deveria abrir a outra galeria, abre a mesma galeria, no caso a do nível 0, quando deveria abrir a galeria correspondente ao Name em seus níveis correspondentes. Creio que a solução está no ID. Já tentei de tudo e nada funciona.
4)Os códigos originais dos scripts estão aqui: http://rodrigokurtz.com/galeria/galeriasoriginais.rar
5)Como estou com o tempo esgotado, e o desespero bateu, minha alternativa é pagar ou esperar uma ajuda autruísta. Recompenso no caso de me ajudarem, é só mandar um mail no eu@rodrigokurtz.com caso encontrem a solução com o preço desejado pelo trabalho.
É isso aí...
Abs,
Rodrigo
Carregando comentários...