Amigos, mais uma vez eu aqui pedindo um socorro. Estou fazendo um site em flash, mas como não sei quase nada de Flash, as e xml, vou aprendendo com cópias, modelos e muito erro. Numa área do site usei um modelo de uma galeria de imagens - Polaroid Gallery (v 1.01) - que serviu bem para o que eu precisava depois de algumas adaptações. Há um exemplo desse template aqui: http://www.no3dfx.com/polaroid/. O problema é que não consigo resolver uma das coisas que preciso criar sobre o modelo e emperrei o projeto. O pior é que acho que é relativamente simples... Mas pra mim tá dificil. Agradeceria muito qualquer ajuda! O modelo abre um novo mc quando o usuário clica em uma das imagens reduzidas. Esse novo mc exibe a imagem maior e tem dois botões, para avançar ou retroceder para outra imagem. (Como podem ver no link com exemplo que postei acima). O que quero: Adicionar um terceiro botão que ao clicar chama uma outra página (getURL, _blank) com uma imagem referenciada na linha do XML que indica a imagem carregada no mc. O que fiz até agora: criei o novo botão no template (que seguindo o modelo é um mc). Atribui nome, criei uma nova função no as. Até aí eu fui. Qual o problema: Não consigo (não sei como fazer e já tentei muita coisa) indicar no código a atribuição de uma variável relativa ao caminho da imagem que foi carregada no mc e que está indicada no arquivo xml. Alguém poderia dar uma luz? Segue o código que estou usando. Não liguem, por favor, que está cheio de remendos e modificações que fui fazendo e testando para adaptar ao meu projeto. Para explicar o que tentei abaixo: criei a função visAbrir() que está no bloco //nova função// que é chamada ao clicar no botão que criei. Isto funcionou. Mas o que quero é carregar para ela a url da imagem, que está no tag url do arquivo xml. ////////////////////////////////
// Project: Polaroid Gallery (v 1.01)
// Author: Christopher Einarsrud
// Edited: 16/07/2007
// This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 License.
// For more information, read http://creativecommons.org/licenses/by-nc/3.0/
////////////////////////////////
////////////////////////////////
// <imports>
import flash.filters.*;
import flash.display.BitmapData;
// </imports>
////////////////////////////////
////////////////////////////////
// <vars>
var photoHolder = new Array();
var skalerTempo = 3;
var thumbStr = 15;
var stageHeight = Stage.height;
var stageWidth = Stage.width;
//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");
// </vars>
////////////////////////////////
////////////////////////////////
// <init>
_root.createEmptyMovieClip("bakgrunsHolder",_root.getNextHighestDepth());
_root.createEmptyMovieClip("sideGlow", _root.getNextHighestDepth());
// </init>
////////////////////////////////
////////////////////////////////
// <generer fotovariabler>
flickrTAGS = (flickrTAGS) ? flickrTAGS:"";
xmlURL = (xmlURL) ? xmlURL:"photos.xml";
xmlURL = (flickrID) ? "http://api.flickr.com/services/feeds/photos_public.gne?id="+flickrID+"&tags="+flickrTAGS+"&tagmode=any&format=rss_200":xmlURL;
////
// Flickr feed
////
var loadet_xml:XML = new XML();
loadet_xml.ignoreWhite = true;
loadet_xml.onLoad = function (success){
var loop = (flickrID) ? loadet_xml.firstChild.firstChild.childNodes:loadet_xml.firstChild.childNodes;
var num = 0;
if (flickrID) {
for (var i = 0;i < loop.length;i++) {
if (loop[i].nodeName == "item") {
var loop2 = loop[i].childNodes;
photoHolder[num] = new Array();
for (var i2 = 0;i2 < loop2.length;i2++) {
if (loop2[i2].nodeName == "media:content") {
photoHolder[num].url = loop2[i2].attributes.url;
}
else if (loop2[i2].nodeName == "title") {
photoHolder[num].desc = loop2[i2].firstChild;
}
}
num++;
}
}
}
else {
for (i=0;i < loop.length;i++) {
photoHolder[i] = loop[i].attributes;
}
}
delete loadet_xml;
byggBilder();
}
loadet_xml.load(xmlURL);
// </generer fotovariabler>
////////////////////////////////
////////////////////////////////
// <bygg polaroids>
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;
var nx = photoHolder[i].desc;
if (Math.round(Math.random()*1) == 1) {
// tilfeldig y akse
mc._y = (mural._height*Math.random())+(mural._y+15);
if (Math.round(Math.random()*1) == 1) mc._x = (mc._width)+mural._x;
else mc._x = (mc._width)+(mural._x);
}
else {
// tilfeldig x akse
mc._x = (mural._width*Math.random())+(mural._x);
if (Math.round(Math.random()*1) == 1) mc._y = (mc._height*2)+mural._y;
else mc._y = (mc._height)+((mural._y)*Math.random())+15;
}
mc.newX = Math.round((mural._x) + ((mural._width-mc._width)*Math.random()));
mc.newY = Math.round((mural._y) + ((mural._height-mc._height/2)*Math.random())+30);
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);
var rs = phtoHolder[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 = 1000/mc2._width;
var hP = 455/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._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 += (40-this._xscale)/skalerTempo;
this._yscale += (40-this._yscale)/skalerTempo;
this._rotation += (this.newRotation-this._rotation)/skalerTempo;
//this._x = 100;
//this._y = 230;
//this._x += (((Stage.width/2)-(mural._width/2))-this._x)/skalerTempo;
//this._y += (((Stage.height/2)-(mural._height/2))-this._y)/skalerTempo;
//this._x += ((Stage.width/2)-this._x)/skalerTempo;
//this._y += ((Stage.height/2)-this._y)/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.abrirKnapp.onRelease = function() { visAbrir(mc, photoHolder[i].desc); }
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));
}
//nova funcao//
function visAbrir() {
getURL("mural/dicas/"+mc,"_blank");
}
//nova funcao//
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/2)-200) + (400*(mc._x/stageWidth)));
//mc._y = Math.round(((Stage.height/2)-150) + (300*(mc._y/stageHeight)));
//mc._x = Math.round(Stage.width * (mc._x/stageWidth));
//mc._y = Math.round(Stage.height * (mc._y/stageHeight));
//mc._x = Math.round((Stage.width/2)-(mural._width/2) + (mc._x/mural._width));
//mc._y = Math.round((Stage.height/2)-(mural._height/2) + (mc._y/mural._height));
mc._x = Math.round(mural._width * (mc._x/Stage.width)) + (mural._width);
mc._y = Math.round(mural._height * (mc._y/Stage.height)) + (mural._height);
}
else {
fotoSomBlirVist._x = mural._width/2;
fotoSomBlirVist._y = mural._height/2;
}
//mc.oldX = Math.round(((Stage.width/2)-(mural._width/2)) + (mural._width*(mc.oldX/mural._width)));
//mc.oldY = Math.round(((Stage.height/2)-(mural._height/2)) + (mural._height*(mc.oldY/mural._height)));
//mc.newX = Math.round(((Stage.width/2)-(mural._width/2)) + (mural._width*(mc.newX/mural._width)));
//mc.newY = Math.round(((Stage.height/2)-(mural._height/2)) + (mural._height*(mc.newY/mural._height)));
//mc.startX = Math.round(((Stage.width/2)-(mural._width/2)) + (mural._width*(mc.startX/mural._width)));
//mc.startY = Math.round(((Stage.height/2)-(mural._height/2)) + (mural._height*(mc.startY/mural._height)));
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>
//////////////////////////////// Muito obrigado!