Salve a tutti,
sono nuovo di Action Script ... ho salvato da internet una slide già pronta e fin qui
tutto bene. Quando cambio pulsante dovrei sostituire le immagini dello slide prendendole da un altro file xml.
Secondo me dovrei prima eliminare il riferimento al loader caricato in precedenza
per poi ricaricarne un altro....
Il metodo da utilizzare penso che sia Loader.unload ma non riesco a capire come devo fare
Qualcuono può aiutarmi ??

Il codice è

import caurina.transitions.Tweener;

var auto_play:Boolean = true; // true (OR) false
var auto_play_duration:Number = 3600; // 1 second equals 1000
var folder:String = "photos/";
var timer:Timer;
var i:Number;
var tn:Number = 0;
var pic:Number = 0;
var previous_no:Number = 0;
var current_no:Number = 0;
var tween_duration:Number = 0.8; // seconds
var total:Number;
var flashmo_xml:XML;
var flashmo_photo_list = new Array();
var photo_group:MovieClip = new MovieClip();
var thumbnail_group:MovieClip = new MovieClip();

this.addChild(photo_group);
this.addChild(thumbnail_group);
this.addChild(flashmo_text_bg);

this.addChild(photo_title);
this.addChild(photo_description);
this.addChild(photo_button);
this.addChild(thumbnail_pointer);

photo_button.alpha = 0;
photo_button.buttonMode = true;

photo_group.x = flashmo_photo_area.x;
photo_group.y = flashmo_photo_area.y;
photo_group.mask = flashmo_photo_area;

thumbnail_group.x = flashmo_thumbnail_area.x;
thumbnail_group.y = flashmo_thumbnail_area.y;
flashmo_thumbnail_area.visible = false;

photo_group_info.text = "";
photo_title.text = "";
photo_description.text = "";

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_photo_tab);
}

function create_photo_tab(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(),
url: flashmo_xml.photo[i].url.toString(),
target: flashmo_xml.photo[i].target.toString()
} );
}
load_photo();
load_tn();
photo_title.text = flashmo_xml.photo[0].title.toString();
photo_description.text = flashmo_xml.photo[0].description.toString();
}

function load_photo():void
{
var pic_request:URLRequest = new URLRequest( folder + flashmo_photo_list[pic].filename );
var pic_loader:Loader = new Loader();
pic_loader.load(pic_request);
pic_loader.contentLoaderInfo.addEventListener(Prog ressEvent.PROGRESS, on_photo_progress);
pic_loader.contentLoaderInfo.addEventListener(Even t.COMPLETE, on_photo_loaded);
pic++;
}

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

function on_photo_loaded(e:Event):void
{
if( pic < total )
{
load_photo();
}
else if( auto_play == true )
{
photo_group_info.text = "";

timer = new Timer(auto_play_duration);
timer.addEventListener(TimerEvent.TIMER, auto_play_timer);
timer.start();
}
else
{
photo_group_info.text = "";
}

var flashmo_pic_bm:Bitmap = new Bitmap();
var flashmo_pic_mc:MovieClip = new MovieClip();

flashmo_pic_bm = Bitmap(e.target.content);
flashmo_pic_bm.smoothing = true;

flashmo_pic_mc.addChild( flashmo_pic_bm );
flashmo_pic_mc.name = "flashmo_pic_" + photo_group.numChildren;

if( photo_group.numChildren > 0 )
flashmo_pic_mc.alpha = 0;

photo_group.addChild( flashmo_pic_mc );
}

function auto_play_timer(te:TimerEvent):void
{
current_no++;

if( current_no >= total )
current_no = 0;

change_photo();
}

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(Even t.COMPLETE, on_thumbnail_loaded);
tn++;
}

function on_thumbnail_loaded(e:Event):void
{
if( tn < total )
load_tn();

var flashmo_tn_bm:Bitmap = new Bitmap();
var flashmo_tn_mc:MovieClip = new MovieClip();

flashmo_tn_bm = Bitmap(e.target.content);
flashmo_tn_bm.smoothing = true;

flashmo_tn_mc.addChild(flashmo_tn_bm);
flashmo_tn_mc.name = "flashmo_tn_" + thumbnail_group.numChildren;
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.x = thumbnail_group.numChildren * 95;
flashmo_tn_mc.y = 0;
thumbnail_group.addChild( flashmo_tn_mc );
}

function tn_over(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
Tweener.addTween( mc, { alpha: 0.5, time: tween_duration, transition: "easeIn" } );
}

function tn_out(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
Tweener.addTween( mc, { alpha: 1, time: tween_duration, transition: "easeOut" } );
}

function tn_click(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
current_no = parseInt(mc.name.slice(11,13));
change_photo();
}

function change_photo():void
{
Tweener.addTween( photo_group.getChildAt(previous_no), { alpha: 0, time: tween_duration,
transition: "easeInOutQuart" } );
Tweener.addTween( photo_group.getChildAt(current_no), { alpha: 1, time: tween_duration,
transition: "easeInOutQuart" } );
Tweener.addTween( thumbnail_pointer, { x: current_no * 95 + 10, time: tween_duration,
transition: "easeOut" } );

previous_no = current_no;
photo_title.text = flashmo_photo_list[current_no].title;
photo_description.text = flashmo_photo_list[current_no].description;
}

photo_button.addEventListener( MouseEvent.MOUSE_OVER, pic_over );
photo_button.addEventListener( MouseEvent.MOUSE_OUT, pic_out );
photo_button.addEventListener( MouseEvent.CLICK, pic_click );

function pic_over(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
Tweener.addTween( mc, { alpha: 0.2, time: tween_duration, transition: "easeIn" } );
}

function pic_out(e:MouseEvent):void
{
var mc:MovieClip = MovieClip(e.target);
Tweener.addTween( mc, { alpha: 0, time: tween_duration, transition: "easeOut" } );
}

function pic_click(e:MouseEvent):void
{
navigateToURL( new URLRequest( flashmo_photo_list[current_no].url ),
flashmo_photo_list[current_no].target );
}