Jump to content


Photo

Slide Adaptado - Flash - Img


  • Faça o login para participar
3 replies to this topic

#1 leanjo

leanjo

    Doutor

  • Usuários
  • 912 posts
  • Sexo:Não informado
  • Interesses:...

Posted 14/05/2007, 03:29

opa
peguei um script e adaptei pra poder rodar flash ou imagem no slide...
nao sei se o que adaptei esta certo, mas esta funcionando :)

porem, ele nao roda se alguma imagem do site estiver com caminho errado
ex:
tenho o slide numa div e se alguma imagem que vier no rodape estiver "queimada" o slide nao funciona

queria saber se é o script que esta errado e gostaria de usar sem precisar por <body onload="slide.start()"> é possivel?


valeu galera



<script>
slide = {
	//vetor com os slides
	_imagens : [
["img/publicidade_02.swf","1","_self","1.htm","f"],
["img/2.gif","2","_blank","2","i"],
["img/04.jpg","3","_self","3","i"],
["img/05.jpg","4","_self","4","i"]
		],
	
	// variáveis do sistema
	_count : 0,
	_length : null,
	_timeOutID : null,
	_pause : false,
	_timer : 5,
	
	// função que inicia o slide e seta todas os parâmetros necessários
	start : function(){
		with(this){ _preLoader(); _length = _imagens.length; _work(); }
	},
	
	// faz o pré-carregamento das imagens
	_preLoader : function(){
		for(x in this._imagens){
			var image = new Image();
			image.src = this._imagens[x][0];
		}
	},
	
	// função principal que faz as checagens necessárias
	_work : function(){
		with(this){
			(_count == _length) ? _count = 0 : (_count < 0) ? _count = _length-1 : void(0);
			var current = _imagens[_count];
			_exchange(current);
			if(!_pause){
				(typeof(_timeOutID) == "number") ? clearTimeout(_timeOutID) : void(0);
				_timeOutID = setTimeout(function(){ slide.next(); }, (Number(_timer)*1000));
			}
		}
	},
	
	// função que altera os elementos da página, altere os IDs se necessário
	_exchange : function(img){

altura = '120';
largura = '235';

if (img[4]=="f") 
{

propagandaFlash = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" style="z-index:9997" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="235" height="120" id="dhtmlig" ALIGN="">';
propagandaFlash += '<PARAM NAME="movie" value="'+img[0]+'">';
propagandaFlash += '<PARAM NAME="quality" VALUE="high">';
propagandaFlash += '<PARAM NAME="wmode" VALUE="transparent">';
propagandaFlash += '<PARAM NAME="bgcolor" VALUE="#FFFFFF">';
propagandaFlash += '<EMBED style="z-index:9997" src="'+img[0]+'" quality="high" wmode="transparent" bgcolor="#FFFFFF"  width="'+largura+'" height="'+altura+'" NAME="dhtmlig" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';
propagandaFlash += '</OBJECT>';


//propagandaFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="235" height="120" id="img/publicidade_02" align="middle">';
//propagandaFlash += '<param name="allowScriptAccess" value="sameDomain" />';
//propagandaFlash += '<param name="movie" value="'+img[0]+'" />';
//propagandaFlash += '<param name="quality" value="high" />';
//propagandaFlash += '<param name="bgcolor" value="#ffffff" />';
//propagandaFlash += '<embed src="'+img[1]+'" quality="high" bgcolor="#ffffff" width="243" height="120" name="img/publicidade_02" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
//propagandaFlash += '</object>';


document.getElementById("linkfoto").innerHTML = propagandaFlash

document.getElementById("linkSlide").innerHTML = img[1];
}

else
{

		document.getElementById("linkfoto").target = img[2];
		document.getElementById("linkfoto").href = img[3];
		document.getElementById("linkfoto").innerHTML = '<img src="'+img[0]+'" width="'+largura+'" height="'+altura+'" />';

		document.getElementById("linkSlide").innerHTML = img[1];

		document.getElementById("linkSlide").target = img[2];
		document.getElementById("linkSlide").href = img[3];	
}
		
	},
	
	// altera para o próximo slide ao clicar no botão Próximo
	next : function(){
		with(this){ _count++; _work(); }
	},
	
	// altera para o slide anterior ao clicar no botão correspondente
	previous : function(){
		with(this){ _count--; _work(); }
	},
	

	// controla o tempo de troca de cada slide
	tControl : function(act){
		with(this){
		(act=="m")?((_timer==4)?void(0):_timer=_timer-1):((_timer==9)?void(0):_timer= _timer +1);
			document.getElementById('showTimer').innerHTML = _timer+"s";	
		}
		
	}	
}
</script>

Edição feita por: leanjo, 14/05/2007, 03:30.


#2 bimonti

bimonti

    Super Veterano

  • Usuários
  • 2654 posts
  • Sexo:Masculino

Posted 14/05/2007, 10:42

Pra não precisar declarar no body faça assim no javascript dentro do head:

<script>
window.onload = function(){ slide.start(); };
</script>

A outra dúvida eu não entendi ... e a propósito, eu já lançei outra versão desse slide, facilita pra alterar o ID dos elementos. Confira no site do projeto se houver interesse: http://my.opera.com/bimonti/
WebFórum - Equipe de Desenvolvimento - Monitor
Posted Image
Yeah I do have some stories, and it's true I want all the glory ...

#3 Dudu

Dudu

    Viva la vida

  • Usuários
  • 1437 posts
  • Sexo:Masculino
  • Localidade:Uberlândia - MG
  • Interesses:PHP

Posted 13/12/2007, 13:48

Não consegui fazer funcionar...
Coloquei as divs...

-----------------------------------------------
Editando


Consegui fazer funcionar...
E ainda dei uma adaptada para identificar as imagens de uma pasta...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Untitled Document</title><script>window.onload = function(){ slide.start(); };slide = {    //vetor com os slides    _imagens : [	<?$i = 1;$dir = "./imagens/";$open = opendir($dir);while($img = readdir($open)) {	if($img != "." && $img != ".." && $img != "Thumbs.db") {	$inf = pathinfo($img);	$t = $inf['extension'] == "swf" ? 'f' : 'i';	$size = getimagesize($dir.$img);	?>["<?php echo $dir.$img; ?>","<?php echo $i; ?>","_self","<?php echo $i; ?>","<?php echo $t; ?>", "<?php echo $size[0]; ?>", "<?php echo $size[1]; ?>"],<?	}$i++;}?>        ],        // variáveis do sistema    _count : 0,    _length : null,    _timeOutID : null,    _pause : false,    _timer : 5,        // função que inicia o slide e seta todas os parâmetros necessários    start : function(){        with(this){ _preLoader(); _length = _imagens.length; _work(); }    },        // faz o pré-carregamento das imagens    _preLoader : function(){        for(x in this._imagens){            var image = new Image();            image.src = this._imagens[x][0];        }    },        // função principal que faz as checagens necessárias    _work : function(){        with(this){            (_count == _length) ? _count = 0 : (_count < 0) ? _count = _length-1 : void(0);            var current = _imagens[_count];            _exchange(current);            if(!_pause){                (typeof(_timeOutID) == "number") ? clearTimeout(_timeOutID) : void(0);                _timeOutID = setTimeout(function(){ slide.next(); }, (Number(_timer)*1000));            }        }    },        // função que altera os elementos da página, altere os IDs se necessário    _exchange : function(img){if (img[4]=="f"){propagandaFlash = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" style="z-index:9997" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="235" height="120" id="dhtmlig" ALIGN="">';propagandaFlash += '<PARAM NAME="movie" value="'+img[0]+'">';propagandaFlash += '<PARAM NAME="quality" VALUE="high">';propagandaFlash += '<PARAM NAME="wmode" VALUE="transparent">';propagandaFlash += '<PARAM NAME="bgcolor" VALUE="#FFFFFF">';propagandaFlash += '<EMBED style="z-index:9997" src="'+img[0]+'" quality="high" wmode="transparent" bgcolor="#FFFFFF"  width="'+img[5]+'" height="'+img[6]+'" NAME="dhtmlig" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';propagandaFlash += '</OBJECT>';//propagandaFlash = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="235" height="120" id="img/publicidade_02" align="middle">';//propagandaFlash += '<param name="allowScriptAccess" value="sameDomain" />';//propagandaFlash += '<param name="movie" value="'+img[0]+'" />';//propagandaFlash += '<param name="quality" value="high" />';//propagandaFlash += '<param name="bgcolor" value="#ffffff" />';//propagandaFlash += '<embed src="'+img[1]+'" quality="high" bgcolor="#ffffff" width="243" height="120" name="img/publicidade_02" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';//propagandaFlash += '</object>';document.getElementById("linkfoto").innerHTML = propagandaFlash//document.getElementById("linkSlide").innerHTML = img[1];}else{        document.getElementById("linkfoto").target = img[2];        document.getElementById("linkfoto").href = img[3];        document.getElementById("linkfoto").innerHTML = '<img src="'+img[0]+'" width="'+img[5]+'" height="'+img[6]+'" />';        //document.getElementById("linkSlide").innerHTML = img[1];        document.getElementById("linkSlide").target = img[2];        document.getElementById("linkSlide").href = img[3];    }            },        // altera para o próximo slide ao clicar no botão Próximo    next : function(){        with(this){ _count++; _work(); }    },        // altera para o slide anterior ao clicar no botão correspondente    previous : function(){        with(this){ _count--; _work(); }    },        // controla o tempo de troca de cada slide    tControl : function(act){        with(this){        (act=="m")?((_timer==4)?void(0):_timer=_timer-1)<img src='http://forum.wmonline.com.br/public/style_emoticons/<#EMO_DIR#>/sad.gif' class='bbc_emoticon' alt=':(' />(_timer==9)?void(0):_timer= _timer +1);            document.getElementById('showTimer').innerHTML = _timer+"s";            }            }    }</script></head><body><div id="showTimer"></div><div id="linkfoto"></div><div id="linkSlide"></div></body></html>


Adicionei mais 2 parâmetros no vetor imagens. O largura e o Altura.
Assim, irá gerar a imagem e ela não irá ficar distorcida.


Até mais ^_^

Edição feita por: _Dudu_1533, 13/12/2007, 14:19.

Fórum WMO - Equipe de Desenvolvimento / Banco de Dados - Moderador


Twitter: HostCheap


#4 bimonti

bimonti

    Super Veterano

  • Usuários
  • 2654 posts
  • Sexo:Masculino

Posted 13/12/2007, 21:49

Excelente. Estou movendo os projetos para meu blog novo. Se você autorizar, depois eu posto sua alteração para outros usuários.
WebFórum - Equipe de Desenvolvimento - Monitor
Posted Image
Yeah I do have some stories, and it's true I want all the glory ...




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq