Fichier xml ne se charge pas totalement

beha33300 Messages postés 5 Date d'inscription lundi 29 juin 2009 Statut Membre Dernière intervention 4 avril 2010 - 3 avril 2010 à 07:58
beha33300 Messages postés 5 Date d'inscription lundi 29 juin 2009 Statut Membre Dernière intervention 4 avril 2010 - 3 avril 2010 à 08:09
bonjour a tous,

je mets en place une galerie photos en AS3 avec chargement d'un fichier xml que j'ai telechargé sur internet.

tout ce passe très bien. les visuels s'affichent dans l'ordre, coherence visuelle entre les vignettes et l'aperçu de plus grande taille, pas de message d'erreur... tout va bien !

sauf... que tous mes visuels ne s'affichent pas en totalité!
je m'explique : les vignettes s'affichent en totalité (120 sur 120) mais pas les aperçus (110 sur 120) !

je fais des trace, et cela me confirme bien qu'il ne genere que 110 sur 120 !

avez vous une idée du probleme?

je vous donne le code : il est un peu long mais peut etre qu'un oeil averti detectera mieux que mon oeil endormi !



///////CODE/////////


import caurina.transitions.*;

var folder:String = "photos/";
var follow_mouse:Boolean = true; // true OR false
var tween_duration:Number = 0.1;
var default_tn_scale:Number = 0.8;
var default_pic_alpha:Number = 0.20;
var new_scale:Number;
var tn_border:Number = 5;
var speed:Number = 5; // from 1 to 20
var i:Number;
var j:Number;
var tn:Number = 0;
var tn_distance:Number;
var current_no:Number = 0;
var total:Number;
var max:Number = 255;
var flashmo_xml:XML;
var flashmo_photo_list = new Array();
var current_mc:MovieClip = new MovieClip();
var flashmo_pic:MovieClip = new MovieClip();
var thumbnail_group:MovieClip = new MovieClip();

this.addChild(flashmo_pic);
this.addChild(thumbnail_group);
this.addChild(flashmo_text_info);

flashmo_pic.alpha = default_pic_alpha;
flashmo_pic.x = flashmo_photo_area.x;
flashmo_pic.y = flashmo_photo_area.y;
flashmo_pic.mask = flashmo_photo_area;

thumbnail_group.x = 100;
thumbnail_group.y = flashmo_thumbnail_area.y;
thumbnail_group.mask = flashmo_thumbnail_area;

loading_info.text = "";
thumbnail_info.text = "";
flashmo_photo_title.text = "";
flashmo_text_info.alpha = 0;
flashmo_text_info.photo_title.text = "";
flashmo_text_info.photo_description.text = "";

if( Math.abs(speed) > 20 ) speed = 10;
speed = Math.abs(speed);

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 = flashmo_xml.photo.length();

for( i = 0; i < total; 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_photo();
load_tn();
trace (total);
}

function load_photo():void
{
var pic_request:URLRequest = new URLRequest( folder + flashmo_photo_list[current_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);

flashmo_text_info.photo_title.text = flashmo_photo_list[current_no].title;
flashmo_text_info.photo_description.text = flashmo_photo_list[current_no].description;
flashmo_pic.alpha = 0;
}

function unload_photo():void
{
flashmo_pic.removeChildAt(0);
load_photo();
trace (total);
}

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

function on_photo_loaded(e:Event):void
{
loading_info.text = "";
flashmo_pic.addChild( Bitmap(e.target.content) );
flashmo_pic.addEventListener( MouseEvent.MOUSE_OVER, pic_over );
flashmo_pic.addEventListener( MouseEvent.MOUSE_OUT, pic_out );
Tweener.addTween( flashmo_pic, { alpha: default_pic_alpha, time: tween_duration, transition: "easeOutQuart" } );
thumbnail_group.addEventListener( MouseEvent.MOUSE_OVER, pic_over );
}

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++;
thumbnail_info.text = "Chargement " + tn + " sur " + total;

if( tn == 8 )
thumbnail_group.addEventListener( Event.ENTER_FRAME, fisheye_thumbnails );
}

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;
flashmo_tn_bm.smoothing = true;

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

flashmo_tn_mc.graphics.beginFill(0xFFFFFF);
flashmo_tn_mc.graphics.drawRect( - bg_width * 0.5, - bg_height + tn_border, 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.x = thumbnail_group.numChildren * 80;
flashmo_tn_mc.y = 110;
flashmo_tn_mc.scaleX flashmo_tn_mc.scaleY default_tn_scale;
thumbnail_group.addChild(flashmo_tn_mc);

if( tn < total )
load_tn();
else
thumbnail_info.text = "";
}

function tn_over(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
var s_no:Number = parseInt(mc.name.slice(8,10));

if( s_no > 1 )
thumbnail_group.addChild( thumbnail_group.getChildByName("flashmo_" + (s_no-2) ) );
if( s_no > 0 )
thumbnail_group.addChild( thumbnail_group.getChildByName("flashmo_" + (s_no-1) ) );
if( s_no < thumbnail_group.numChildren - 2 )
thumbnail_group.addChild( thumbnail_group.getChildByName("flashmo_" + (s_no+2) ) );
if( s_no < thumbnail_group.numChildren - 1 )
thumbnail_group.addChild( thumbnail_group.getChildByName("flashmo_" + (s_no+1) ) );

thumbnail_group.addChild(mc);
flashmo_photo_title.text = flashmo_photo_list[s_no].title;
}

function tn_out(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
thumbnail_group.addChild(mc);
flashmo_photo_title.text = "";
}

function tn_click(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
current_no = parseInt(mc.name.slice(8,10));
Tweener.addTween( flashmo_pic, { alpha: 0, time: tween_duration,
transition: "easeInQuart", onComplete: unload_photo } );
flashmo_pic.removeEventListener( MouseEvent.MOUSE_OVER, pic_over );
flashmo_pic.removeEventListener( MouseEvent.MOUSE_OUT, pic_out );
thumbnail_group.removeEventListener( MouseEvent.MOUSE_OVER, pic_over );
}

flashmo_text_info.addEventListener( MouseEvent.MOUSE_OVER, info_over );
flashmo_text_info.addEventListener( MouseEvent.MOUSE_OUT, info_out );

function pic_over(e:MouseEvent):void
{
Tweener.addTween( flashmo_pic, { alpha: default_pic_alpha, time: tween_duration, transition: "easeIn" } );
Tweener.addTween( thumbnail_group, { alpha: 1, time: tween_duration, transition: "easeOut" } );
}

function pic_out(e:MouseEvent):void
{
Tweener.addTween( flashmo_pic, { alpha: 1, time: tween_duration, transition: "easeOut" } );
Tweener.addTween( thumbnail_group, { alpha: 0, time: tween_duration, transition: "easeIn" } );
}

function info_over(e:MouseEvent):void
{
Tweener.addTween( flashmo_pic, { alpha: 1, time: tween_duration, transition: "easeOut" } );
Tweener.addTween( thumbnail_group, { alpha: 0, time: tween_duration, transition: "easeIn" } );
Tweener.addTween( flashmo_text_info, { alpha: 1, time: tween_duration, transition: "easeIn" } );
}

function info_out(e:MouseEvent):void
{
Tweener.addTween( flashmo_text_info, { alpha: 0, time: tween_duration, transition: "easeOut" } );
}

function fisheye_thumbnails(e:Event):void
{
thumbnail_group.x -= ( mouseX - flashmo_thumbnail_area.width * 0.5 ) * 0.005 * speed;

if( thumbnail_group.x > flashmo_thumbnail_area.x + 100 )
{
thumbnail_group.x = flashmo_thumbnail_area.x + 100;
}
else if( thumbnail_group.x < flashmo_thumbnail_area.x - thumbnail_group.width + flashmo_thumbnail_area.width )
{
thumbnail_group.x = flashmo_thumbnail_area.x - thumbnail_group.width + flashmo_thumbnail_area.width;
}

if( mouseY > flashmo_thumbnail_area.y && mouseY < flashmo_thumbnail_area.y + flashmo_thumbnail_area.height )
{
for( j = 0; j < thumbnail_group.numChildren; j++ )
{
current_mc = MovieClip(thumbnail_group.getChildAt(j));
tn_distance = Math.sqrt(
Math.pow( Math.abs( mouseX - (current_mc.x + thumbnail_group.x) ) , 2)
+ Math.pow( Math.abs( mouseY - (current_mc.y + thumbnail_group.y) ) , 2)
);
new_scale = 1.1 - ( tn_distance * 0.002 );
current_mc.scaleX += (new_scale - current_mc.scaleX) * 0.2;
current_mc.scaleY += (new_scale - current_mc.scaleY) * 0.2;
if( current_mc.scaleX < default_tn_scale )
current_mc.scaleX current_mc.scaleY default_tn_scale;
}
}
else
{
for( j = 0; j < thumbnail_group.numChildren; j++ )
{
current_mc = MovieClip(thumbnail_group.getChildAt(j));
current_mc.scaleX += (default_tn_scale - current_mc.scaleX) * 0.2;
current_mc.scaleY += (default_tn_scale - current_mc.scaleY) * 0.2;
}
}
}



MERCI ENCORE POUR VOTRE AIDE en esperant que ca me resolve mon pb !!!

1 réponse

beha33300 Messages postés 5 Date d'inscription lundi 29 juin 2009 Statut Membre Dernière intervention 4 avril 2010
3 avril 2010 à 08:09
oups j'ai oublié de preciser autre chose !

en fait a partir de 110 en cliquant sur les vignettes restantes (111 à 120) (qui s'affichent très bien! pas de souci de ce coté la !), cela n'affiche que la meme photo. Donc entre 111 et 120 j'ai toujours le meme visuel qui fait bien parti aussi de ma liste de photos.

j'ai verifié plrs fois mon fichier xml et c'est bien les memes noms que dans mon dossier "photos".

ce que je ne comprends pas c'est pourquoi j'ai 20 fois la meme photo en fin de liste d'apparition et pourquoi je n'ai aucun message d'erreur !!!


j'espere que j'ai ete assez clair !!

ENCORE MERCI POUR VOTRE AIDE
0
Rejoignez-nous