Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

leandro santiago

Exibir imagens em colunas

Recommended Posts

Olá galera

 

Fiz este codigo, mas não consigo de nenhuma maneira fazer q ele exiba o resulado em 2 coluas.

 

o codigo é o seguinte

 

var meuXML = new XML();
meuXML.ignoreWhite = true;
meuXML.onLoad = function ()
{
    altura = thumb._height * meuXML.childNodes[0].childNodes.length + meuXML.childNodes[0].childNodes.length * 2;
    if (altura <= _root.rolagem._height)
    {
        _root.rolagem._visible = false;
    } // end if
	
    for (i = 0; i < meuXML.childNodes[0].childNodes.length; i++)
    {
        duplicateMovieClip("thumb", "thumb" + i, i + 1);
        thumbs = _root.tudo_mc["thumb" + i];
        thumbs._y = thumbs._y + (thumb._height + 2) * i;				
        var MCL1 = new MovieClipLoader();
        MCL1.loadClip(meuXML.childNodes[0].childNodes[i].attributes.thumb, thumbs.mostra);
        thumbs.onEnterFrame = function ()
        {
            progresso1 = MCL1.getProgress(this.mostra);
            this.pct_thumb.text = Math.ceil(progresso1.bytesLoaded / progresso1.bytesTotal * 100) + "%";
            progresso1.bytesLoaded == progresso1.bytesTotal ? (this.pct_thumb._visible = false) : (this.pct_thumb._visible = true);
        };
        thumbs.atual = i;
        thumbs.btn.onRelease = function ()
        {
            var MCL2 = new MovieClipLoader();
            MCL2.loadClip(meuXML.childNodes[0].childNodes[this._parent.atual].attributes.medio, _root.mc);
            this.onEnterFrame = function ()
            {
                progresso2 = MCL2.getProgress(_root.mc);
                _root.pct.text = Math.round(progresso2.bytesLoaded / progresso2.bytesTotal * 100) + "%";
                progresso2.bytesLoaded == progresso2.bytesTotal ? (_root.pct._visible = false) : (_root.pct._visible = true);
            };
            var MCL3 = new MovieClipLoader();
            MCL3.loadClip(meuXML.childNodes[0].childNodes[this._parent.atual].attributes.grande, _root.mc3);
            this.onEnterFrame = function ()
            {
                progresso3 = MCL3.getProgress(_root.mc3);
                _root.pct3.text = Math.round(progresso3.bytesLoaded / progresso3.bytesTotal * 100) + "%";
                progresso3.bytesLoaded == progresso3.bytesTotal ? (_root.pct3._visible = false) : (_root.pct3._visible = true);
            };
            _root.descricao.htmlText = meuXML.childNodes[0].childNodes[this._parent.atual].childNodes;
            _root.descricao.htmlText = _root.descricao.text;
        };
        thumbs.btn.onRollOver = function ()
        {
            _root.tudo_mc["thumb" + this._parent.atual].mostra.contrastTo(50, 1);
        };
        thumbs.btn.onRollOut = function ()
        {
            _root.tudo_mc["thumb" + this._parent.atual].mostra.contrastTo(100, 1);
        };
    } // end of for
    _root.rolagem.drag.onPress = function ()
    {
        var _loc4 = this._x;
        var _loc3 = this._x;
        var _loc5 = 0;
        var ymax = this._parent.fundo._height - this._height;
        this.startDrag(false, _loc4, _loc5, _loc3, ymax);
        this.onRelease = this.onReleaseOutside = function ()
        {
            stopDrag ();
            delete this.onMouseMove();
        };
        this.onEnterFrame = function ()
        {
            _root.tudo_mc._y = _root.tudo_mc._y + (-Math.round(this._y / ymax * (altura - _root.rolagem._height)) - _root.tudo_mc._y) / 3;
        };
    };
};
meuXML.load("campanha.xml");

 

agradeço a ajuda

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá não li bem o código mas este problema é mais lógica do que programação que pelo visto você sabe programar, então basta inserir uma regra dentro do seu loop onde tem o duplicateMovieClip, é só inserir uma condição, ou melhor 1º:

 

$total = meuXML.childNodes[0].childNodes.length;//saber quantos registros, 
$registros_porColuna = 5;// quantos registros por coluna 
$colunas = $total/10;// quantas colunas vão ser criadas
$cont = 0;//criar um cohtador para largura
$i = 0;//criar um cohtador para condição if
$largura_da_coluna = 60;// Suposta largura da coluna

for ($c=0; $c<30; $c++) {
	duplicateMovieClip("alvo", "alvo"+$c, $c);
	eval("alvo"+$c)._y = $i*60;
	if ($i<$registros_porColuna) {
		trace($cont);
		$i++;
		eval("alvo"+$c)._x = $cont*$largura_da_coluna;
	} else {
		$i = 0;
		$cont++;
	}
}

Com isso acho que já consegue resolver aí.

Abraço

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá cara

 

Adaptei o codigo mas ficou com um erro, coloquei para exibir 7 imagens por coluna, mas na primeira ele mostra 8 e na segunda 6.

 

O codigo ficou assim:

 

$total = meuXML.childNodes[0].childNodes.length;//saber quantos registros, 
$registros_porColuna = 7;// quantos registros por coluna 
$cont = 0;//criar um cohtador para largura
$i = 0;//criar um cohtador para condição if
$largura_da_coluna = 50;// Suposta largura da coluna

    for (i = 0; i < $total; i++)
    {
		duplicateMovieClip("thumb", "thumb" + i, i + 1);
		thumbs = _root.tudo_mc["thumb" + i];
        thumbs._y = thumbs._y + $i * 72;
		if ($i < $registros_porColuna) {
                trace($cont);
                $i++;
				thumbs._x = thumbs._x + $cont * $largura_da_coluna;
        } else {
                $i = 0;
                $cont++;
        }

Compartilhar este post


Link para o post
Compartilhar em outros sites

olá, fiz aqui no meu código pois não entendi o seu muito bem, então adapte aí.

 

$total = meuXML.childNodes[0].childNodes.length;//saber quantos registros, 
$registros_porColuna = 5;// quantos registros por coluna 
$colunas = $total/10;// quantas colunas vão ser criadas
$cont = 0;//criar um cohtador para largura
$i = 0;//criar um cohtador para condição if
$largura_da_coluna = 60;// Suposta largura da coluna

for ($c=0; $c<30; $c++) {
        duplicateMovieClip("alvo", "alvo"+$c, $c);       
        if ($i<$registros_porColuna) {
		eval("alvo"+$c)._y = $i*60; // coloquei isto dentro do if
                $i++;
                eval("alvo"+$c)._x = $cont*$largura_da_coluna;
        } else {
                $i = 0;
                $cont++;
        }
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.