Frank Souza 0 Denunciar post Postado Julho 3, 2009 Coloquei o "movieClipLoader" no título do tópico pq suponho que o problema esteja nele.... Meu problema é o seguinte, estou montando uma galeria simples de imagens, fiz tudo direitinho (supostamente), as imagens são carregadas de um BD mySQL normalmente, porém depois de um tempo (+/- 1 minuto) após o carregamento, todas as imagens somem, do nada. aqui o link da página com o swf >> http://72.29.94.142/~inteccsd/web/testes/t...ste1/teste.html quem quiser pode baixar o .FLA para testar, pode rodar localmente, ele baixa tudo diretamente desse domínio >> http://72.29.94.142/~inteccsd/web/testes/t...este1/teste.fla segue o código AS //criando função de substituição de textos em strings String.prototype.replace = function(texto, replacetext) { return this.split(texto).join(replacetext); }; //Criando a função PlayTo com prototype para todos os movieclips MovieClip.prototype.playTo = function (destino) { this.onEnterFrame = function() { if (this._currentframe < destino) { this.nextFrame(); } else if (this._currentframe > destino) { this.prevFrame(); } else if (this._currentframe == destino) { delete this.onEnterFrame; } } } function carrega_imagem(id, arquivo, titulo, posX, posY){ tmb = "thumb_" + id; attachMovie("thumb",tmb, id, {_x:posX,_y:posY}); var wdt = this[tmb].moldura._width; //definindo a largura da thumb, para ser acessado posteriormente var hgt = this[tmb].moldura._height; //definindo a altura da thumb, para ser acessado posteriormente with(this[tmb].foto) { //Criando o listener para detectar quando o carregamento da imagem termina var mclListener:Object = new Object(); mclListener.onLoadProgress = function(mc, bt, tt):Void { var pc = Math.round((bt/tt)*100); //exibimos a porcentagem carregada _parent.porc.text = pc+"%"; }; mclListener.onLoadComplete = function(mc):Void { //ocultamos a porcentagem _parent.porc._visible = false; _alpha = 0; onEnterFrame = function() { this._alpha = this._alpha + 5; if (this._alpha == 100) { delete this.onEnterFrame; } } _parent.titulo.titulo.titulo.text = titulo; }; //Capturando o fim do carregamento mclListener.onLoadInit = function (target_mc:MovieClip) { //Usando a classe Smooth para suavizar a imagem var s = new Smooth(foto); //Posicionando a imagem _x = wdt/2; _y = hgt/2; //Redimensionando a imagem para o tamanho da thumb if (foto._width > foto._height) { foto._width = (hgt*foto._width)/foto._height; foto._height = hgt; } else if (foto._width < foto._height) { foto._height = (wdt*foto._height)/foto._width; foto._width = wdt; } else if (foto._width == foto._height) { //utilizado somente se a altura da moldura for maior que a largura, ou seja, em formato retrato foto._height = hgt; foto._width = foto._height; } foto._x = foto._x - (foto._width/2); foto._y = foto._y - (foto._height/2); } //Adicionando o listener a um MovieClipLoader var image_mcl:MovieClipLoader = new MovieClipLoader(); image_mcl.addListener(mclListener); //Essa linha é a que você vai trocar pelo seu loadMovie (sendo o tester_mc o mc que vai carregar a foto). image_mcl.loadClip(arquivo, foto); } } _global.caminho = "http://72.29.94.142/~inteccsd/web/testes/testes-flash-mysql/teste1/"; var dados:Array = new Array(); var varLoad:LoadVars = new LoadVars(); varLoad.load(caminho + 'retorno.php'); varLoad.onLoad = carregar_dados; function carregar_dados():Void{ // Executa um loop até chegar ao número total de resultados. if(this.loaded) { loops = parseInt(this.loops); trace("Arquivo de variáveis carregado: " + loops); for(var l:Number = 0; l < parseInt(this.loops); l++){ dados['id' + l] = this['id' + l]; dados['caminho' + l] = this['caminho' + l]; dados['titulo' + l] = this['titulo' + l]; trace(dados['id' + l] + ' - ' + dados['caminho' + l] + ': ' + dados['titulo' + l]); tudo_carregado = true; }; } else { trace("Arquivo de variáveis não encontrado"); } }; onEnterFrame = function() { if (tudo_carregado) { //relacionado às variáveis, não aos arquivos de imagens //daqui pra frente substitui o for por umas rotinas mais arqcaicas //pois se utilizasse o laço for if (i == undefined){ i = 0; q = loops; cont_linha = 0; posy = 0; posx = 0; } else if (i < q) { j = i + 1; if (cont_linha == 4) { cont_linha = 0; posy = posy + 170; posx = 0; } carrega_imagem(getNextHighestDepth(),caminho + dados['caminho' + i].replace(" ","%20"),dados['titulo' + i],posx,posy); posx = posx + 145; i++; cont_linha++; } else if (i == q){ delete onEnterFrame; } } } Compartilhar este post Link para o post Compartilhar em outros sites
Frank Souza 0 Denunciar post Postado Julho 3, 2009 Problema resolvido, pra tiver um problema semelhante, o erro era minúsculo, porém com grandes consequencias. O errro estava aqui mclListener.onLoadComplete = function(mc):Void { //ocultamos a porcentagem _parent.porc._visible = false; _alpha = 0; onEnterFrame = function() { this._alpha = this._alpha + 5; if (this._alpha == 100) { delete this.onEnterFrame; } } _parent.titulo.titulo.titulo.text = titulo; }; Nessa parte >> o evento onEnterFrame (this._alpha == 100), o alpha do movieclip estava indo acima de 100, sobrecarregando a memória. Substitui por (this._alpha >= 100) simples.. Vlw Compartilhar este post Link para o post Compartilhar em outros sites