Ir para conteúdo

POWERED BY:

Arquivado

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

_Brunoo_

Link em as3 com xml

Recommended Posts

bom dia , peguei uma galeria em as3 pronta do flashmo e estava precisando mudar uma coisa , queria que ao inves de abrir a imagem maior , na hora que clico no thumb tivesse um link

 

link da galeria: galeria

o codigo e este :

 

import caurina.transitions.*;
var folder:String = "photos/";
var css_file:String = "flashmo_202_style.css";
var show_tooltip:Boolean = false;	// true OR false
var tween_duration:Number = 0.6;
var tween_delay:Number = 0;
var tn_alpha:Number = 0.9;
var tn_spacing:Number = 15;
var tn_border:Number = 0;
var tn_border_color:Number = 0xAAAAAA;
var max_tn_width:Number = 140;
var max_tn_height:Number = 170;
var tn_width:Number;
var tn_height:Number;

var i:Number;
var j:Number;
var tn:Number = 0;
var current_pic_no:Number = 0;
var current_page_no:Number = 0;
var start_from:Number = 0;
var end_to:Number;
var total_pages:Number;
var no_of_columns:Number = 5;
var no_of_rows:Number = 2;
var no_of_thumbnails:Number = no_of_columns * no_of_rows;
var total_items:Number;

var css_loader:URLLoader = new URLLoader();
var flashmo_style:StyleSheet = new StyleSheet();
var flashmo_xml:XML;
var flashmo_photo_list = new Array();
var flashmo_pic:MovieClip = new MovieClip();
var thumbnail_group:MovieClip = new MovieClip();
var mc:MovieClip = new MovieClip();

this.addChild(thumbnail_group);
this.addChild(flashmo_tooltip);

if( show_tooltip == false )
{
this.removeChild(flashmo_tooltip);
}
else
{
flashmo_tooltip.visible = false;
flashmo_tooltip.addEventListener( Event.ENTER_FRAME, tooltip );
}

flashmo_pic.addEventListener( MouseEvent.CLICK, pic_click );
flashmo_pic_info.x = -3000;

thumbnail_group.x = ( max_tn_width + tn_border ) * 0.5;
thumbnail_group.y = ( max_tn_height + tn_border ) * 0.5;

thumbnail_sketch.visible = false;
flashmo_previous.visible = false;
flashmo_next.visible = false;
loading_info.text = "";
thumbnail_counter.text = "";
css_loader.load( new URLRequest(css_file) );
css_loader.addEventListener(Event.COMPLETE, css_complete);

function css_complete(e:Event):void 
{
var css_format:TextFormat = new TextFormat();
flashmo_style.parseCSS(css_loader.data);
flashmo_pic_info.photo_description.styleSheet = flashmo_style;
}

function load_gallery(xml_file:String):void
{
var xml_loader:URLLoader = new URLLoader();
xml_loader.load( new URLRequest( xml_file ) );
xml_loader.addEventListener(Event.COMPLETE, create_thumbnail);
}

function create_thumbnail(e:Event):void
{
flashmo_xml = new XML(e.target.data);
total_items = flashmo_xml.photo.length();
total_pages = Math.ceil( total_items / no_of_thumbnails );

for( i = 0; i < total_items; i++ )
{
	flashmo_photo_list.push( {
		thumbnail: flashmo_xml.photo[i].thumbnail.toString(), 
		filename: flashmo_xml.photo[i].filename.toString(), 
		title: flashmo_xml.photo[i].title.toString(), 
		description: flashmo_xml.photo[i].description.toString()


	} );
}
load_tn();
}

function load_tn():void
{
var pic_request:URLRequest = new URLRequest( folder + flashmo_photo_list[tn].thumbnail );
var pic_loader:Loader = new Loader();
pic_loader.load(pic_request);
pic_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, on_thumbnail_loaded);
tn++;
loading_info.text = "carregando " + tn + " de " + total_items;
}

function on_thumbnail_loaded(e:Event):void
{
var flashmo_tn_bm:Bitmap = new Bitmap();
var flashmo_tn_mc:MovieClip = new MovieClip();

flashmo_tn_bm = Bitmap(e.target.content);
flashmo_tn_bm.x = - flashmo_tn_bm.width * 0.5;
flashmo_tn_bm.y = - flashmo_tn_bm.height * 0.5;
flashmo_tn_bm.smoothing = true;

tn_width = flashmo_tn_bm.width;
tn_height = flashmo_tn_bm.height;

var bg_width:Number = flashmo_tn_bm.width + tn_border * 2;
var bg_height:Number = flashmo_tn_bm.height + tn_border * 2;

if( tn_border > 0 )
{
	flashmo_tn_mc.graphics.beginFill(tn_border_color);
	flashmo_tn_mc.graphics.drawRect( - bg_width * 0.5, - bg_height * 0.5, bg_width, bg_height );
	flashmo_tn_mc.graphics.endFill();
}
flashmo_tn_mc.addChild(flashmo_tn_bm);
flashmo_tn_mc.buttonMode = true;
flashmo_tn_mc.addEventListener( MouseEvent.MOUSE_OVER, tn_over );
flashmo_tn_mc.addEventListener( MouseEvent.MOUSE_OUT, tn_out );
flashmo_tn_mc.addEventListener( MouseEvent.CLICK, tn_click );
flashmo_tn_mc.name = "flashmo_" + thumbnail_group.numChildren;
flashmo_tn_mc.y = 1800;
flashmo_tn_mc.alpha = 0;
thumbnail_group.addChild(flashmo_tn_mc);

if( tn < total_items )
	load_tn();
else
{
	move_in();
	loading_info.text = "";
	flashmo_previous.addEventListener( MouseEvent.CLICK, previous_page );
	flashmo_next.addEventListener( MouseEvent.CLICK, next_page );
}
}

function move_in():void
{
flashmo_previous.visible = true;
flashmo_next.visible = true;

if( current_page_no <= 0 ) 
{	
	current_page_no = 0;
	flashmo_previous.visible = false;
}

if( current_page_no >= total_pages - 1 ) 
{
	current_page_no = total_pages - 1;
	flashmo_next.visible = false;
}

start_from = current_page_no * no_of_thumbnails;
end_to = start_from + no_of_thumbnails;

if( end_to > total_items ) 
	end_to = total_items;

if( total_items > no_of_thumbnails )
	thumbnail_counter.text = (start_from + 1) + "-" + end_to + " de " + total_items + " imagens";

j = 0;

for( i = start_from; i < end_to; i++ )
{
	mc = MovieClip( thumbnail_group.getChildByName("flashmo_" + i) );

	mc.x = Math.floor( j / no_of_rows ) *
			( max_tn_width + tn_border * 2 + tn_spacing ) + ( max_tn_width - mc.width );
	mc.y = 900 + j % no_of_rows *
			( max_tn_height + tn_border * 2 + tn_spacing ) + ( max_tn_height - mc.height );

	Tweener.addTween( mc, {
			y: j % no_of_rows * ( max_tn_height  + tn_border * 2 + tn_spacing ),
			alpha: tn_alpha, time: tween_duration, delay: tween_delay + j * 0.04,
			transition: "easeOutExpo" } );
	j++;
}
}

function move_out():void
{
j = 0;

for( i = start_from; i < end_to; i++ )
{
	mc = MovieClip( thumbnail_group.getChildByName("flashmo_" + i) );

	Tweener.addTween( mc, {
			y: j % no_of_rows * ( max_tn_height  + tn_border * 2 + tn_spacing ) - 900,
			alpha: 0, time: tween_duration, delay: j * 0.04,
			transition: "easeInExpo" } );
	j++;
}
tween_delay = tween_duration; 
move_in();
}

function tn_over(e:MouseEvent):void
{
mc = MovieClip(e.target);
Tweener.addTween( mc, { alpha: 1, time: tween_duration, transition: "easeOutQuart" } );
flashmo_tooltip.visible = true;
flashmo_tooltip.pic_title.text = flashmo_photo_list[ parseInt( mc.name.slice(8,12) ) ].title;
}

function tn_out(e:MouseEvent):void
{
mc = MovieClip(e.target);
Tweener.addTween( mc, { alpha: tn_alpha, time: tween_duration, transition: "easeOutQuart" } );
flashmo_tooltip.visible = false;
}

function tn_click(e:MouseEvent):void
{
mc = MovieClip(e.target);
current_pic_no = parseInt(mc.name.slice(8,12));
load_photo();
thumbnail_group.visible = false;
thumbnail_counter.visible = false;
flashmo_previous.visible = false;
flashmo_next.visible = false;
}

function previous_page(e:MouseEvent):void
{
current_page_no--;
move_out();
}

function next_page(e:MouseEvent):void
{
current_page_no++;
move_out();
}

function tooltip(e:Event):void
{
flashmo_tooltip.x = mouseX; // (or) mc.x + 60
flashmo_tooltip.y = mc.y;	// (or) mouseY - 5
}

function load_photo():void
{
var pic_request:URLRequest = new URLRequest( folder + flashmo_photo_list[current_pic_no].filename );
var pic_loader:Loader = new Loader();
pic_loader.load(pic_request);
pic_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, on_photo_progress);
pic_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, on_photo_loaded);

if( flashmo_pic.numChildren > 0 ) 
	flashmo_pic.removeChildAt(0);

this.addChild(flashmo_pic);
this.addChild(flashmo_pic_info);
flashmo_pic_info.photo_title.text = flashmo_photo_list[current_pic_no].title;
flashmo_pic_info.photo_description.htmlText = flashmo_photo_list[current_pic_no].description;
}

function unload_photo():void
{
this.removeChild(flashmo_pic);
}

function on_photo_progress(e:ProgressEvent):void
{
var percent:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);
var filesize:Number = Math.round(e.bytesTotal / 1024);
loading_info.text = "carregando... " + percent + "% (" + filesize + "KB)";
}

function on_photo_loaded(e:Event):void
{
loading_info.text = "";
flashmo_pic.alpha = 0;
flashmo_pic.addChild( Bitmap(e.target.content) );
flashmo_pic.addEventListener( Event.ENTER_FRAME, detect_mouse );

Tweener.addTween( flashmo_pic, { alpha: 1, time: tween_duration, transition: "easeOut" } );
flashmo_pic_info.x = flashmo_pic.x = ( stage.stageWidth - flashmo_pic.width ) * 0.5 - this.parent.x;
flashmo_pic_info.y = flashmo_pic.y = ( stage.stageHeight - flashmo_pic.height ) * 0.5 - this.parent.y;
}

function pic_click(e:MouseEvent):void
{
flashmo_pic_info.visible = false;
thumbnail_group.visible = true;
thumbnail_counter.visible = true;
tween_delay = 0; 
move_in();
flashmo_pic.removeEventListener( Event.ENTER_FRAME, detect_mouse );
Tweener.addTween( flashmo_pic, { alpha: 0, time: tween_duration,
				  transition: "easeIn", onComplete: unload_photo } );
}

function detect_mouse(e:Event):void
{
if( mouseX > flashmo_pic_info.x && mouseX < flashmo_pic_info.width &&
	mouseY > flashmo_pic_info.y && mouseY < flashmo_pic_info.height )
	flashmo_pic_info.visible = true;
else
	flashmo_pic_info.visible = false;
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Você vai no xml e altere onde vai poe o link das fotos e adiciona um campo chamado url da seguinte forma:

<url>www.linkdapaginaqui.com.br</url>

 

ou

 

<url><![CDATA[www.linkdapaginaqui.com.br]]></url> - recomendo esse

 

e no flash vai localizar o bloco de códigos

function tn_click(e:MouseEvent):void
{
       mc = MovieClip(e.target);
       current_pic_no = parseInt(mc.name.slice(8,12));
       load_photo();
       thumbnail_group.visible = false;
       thumbnail_counter.visible = false;
       flashmo_previous.visible = false;
       flashmo_next.visible = false;
}

 

vai deixar assim

function tn_click(e:MouseEvent):void
{

}

 

e em seguida vai preencher com

 

function tn_click(e:MouseEvent):void
{
var abrelinkXml:URLRequest = new URLRequest(xm.ulr[e.target].toString);
navigateToUrl(abrelinkXml);
}

 

cara.. eu não testei, mas acho que isso resolve se não der certo avisa que eu baixo a galeri que você deixou o link e vejo o que fiz errado, ok!

 

Abração!

Compartilhar este post


Link para o post
Compartilhar em outros sites

Você vai no xml e altere onde vai poe o link das fotos e adiciona um campo chamado url da seguinte forma:

<url>www.linkdapaginaqui.com.br</url>

 

ou

 

<url><![CDATA[www.linkdapaginaqui.com.br]]></url> - recomendo esse

 

e no flash vai localizar o bloco de códigos

function tn_click(e:MouseEvent):void
{
       mc = MovieClip(e.target);
       current_pic_no = parseInt(mc.name.slice(8,12));
       load_photo();
       thumbnail_group.visible = false;
       thumbnail_counter.visible = false;
       flashmo_previous.visible = false;
       flashmo_next.visible = false;
}

 

vai deixar assim

function tn_click(e:MouseEvent):void
{

}

 

e em seguida vai preencher com

 

function tn_click(e:MouseEvent):void
{
var abrelinkXml:URLRequest = new URLRequest(xm.ulr[e.target].toString);
navigateToUrl(abrelinkXml);
}

 

cara.. eu não testei, mas acho que isso resolve se não der certo avisa que eu baixo a galeri que você deixou o link e vejo o que fiz errado, ok!

 

Abração!

 

 

Obrigado pela ajuda , mas nao esta dando !! da 2 erros .. sabe o que pode ser?

 

grato

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.