Hello, I hope I could get some help with this issue, since I give up. It is too much for just me.
This script is originally from MX. I have a hard time trying to translate to AS3.
Anyway. There were a moment when I have to mix the original code with the slide show tutorial from kirupa site. Right now is almost functional. But it behave very weird when is online.
My problem is this. After all the work my final touch is to place a preloader to each loaded image(I already made it). But the secuence should be IF LOADED...then execute the FX and summ 1 number to the secuence...
At the end everything works OK, locally, but online the process show the previous images before it get to the preloader secuence of the new comming image. Becouse of this I step a few test behind the actual and noted this:
When the user see the first set of images, everything is OK, but if he move to other, then the listener seem to execute the click function 2 times, becouse the trace window show 2 outputs. At the end we have the right number, but I don't know if this is the problem.
This is the code:
[HTML]import flash.filters.B lurFilter;
import fl.transitions. Tween;
import fl.transitions. easing.*;
import fl.controls.Com boBox;
import flash.events.Ev ent;
import flash.text.Text Field;
import flash.text.Text FieldAutoSize;
import fl.data.DataPro vider;
import flash.text.Text Field;
import flash.text.Text Format;
import flash.display.* ;
import flash.net.URLRe quest;
import fl.transitions. *;
var movider:Number = 35;
var moviizq:Number = -45;
var filename:String = "modelo03.x ml";
//var filename:String = "http://quatpanama.com/qproyectos/convertidor05_f ra.php";
var foundAlbum:Numb er;
var numPhotosOnPage :Number;
var xmlLoader:URLLo ader = new URLLoader();
var album:XML = new XML();
var fileName:String ;
xmlLoader.addEv entListener(Eve nt.COMPLETE, envio);
xmlLoader.load( new URLRequest(file name));
function envio(e:Event): void {
XML.ignoreWhite space = true;
var album:XML = new XML(e.target.da ta);
newAlbum(album) ;
}
function newAlbum(album_ item:XML):void {
for (var e:int=0; e<album_item.le ngth(); e++) {
if (album_item[e].name().localNa me == "albums") {
var albumsDescrypti on:XML = new XML();
albumsDescrypti on = album_item[e];
}
}
buildAlbumList( albumsDescrypti on);
}
var albumCount = 0;
function buildAlbumList( albumsDescrypti on:XML):void {
var albdesc_pars:XM LList = albumsDescrypti on.photoset;
//trace(albdesc_p ars.length());
for (var u:int=0; u<albdesc_pars. length(); u++) {
var albumes_long:Nu mber = albdesc_pars.le ngth();
var album_element:X ML = albdesc_pars[u];
if (album_element. name() == "photoset") {
var etiqueta:String = album_element.a ttribute("name" );
var datos:String = album_element.a ttribute("name" );
combo(etiqueta, datos);
}
}
if (albumCount>0) {
chooseAlbum.sel ectedIndex = 0;
var currentAlbum = chooseAlbum.sel ectedItem.data;
//trace("cierto") ;
//trace(albumDesc );
cambiador();
}
function cambiador() {
var currentAlbum = chooseAlbum.sel ectedItem.data;
var showPhoto = 0;
var isNewAlbum = 1;
var albumselect = chooseAlbum.sel ectedIndex;
album_label.tex t = albdesc_pars[albumselect].attribute("alb um_desc");
findAlbums(albu msDescryption, currentAlbum, showPhoto,isNew Album);
}
////////////FUNCIONS del COMBObox //////////////////////////////////////////////////////////////////////////
//funcion de llenado
function combo() {
albumCount++;
chooseAlbum.add Item( { label: etiqueta, data: datos } );
chooseAlbum.add EventListener(E vent.CHANGE, changeAlbum);
}
//FUNCION DEL CLICK
function changeAlbum (event:Event):v oid{
var currentAlbum = chooseAlbum.sel ectedItem.data;
//trace(currentAl bum);
var showPhoto = 0;
var isNewAlbum = 1;
var albumselect = chooseAlbum.sel ectedIndex;
//trace(albumsele ct);
//album_label.tex t = "wewewe";
//album_label.tex t = albdesc_pars[albumselect].toString();
album_label.tex t = albdesc_pars[albumselect].attribute("alb um_desc");
//trace(albdesc_p ars[albumselect].attribute("alb um_desc"));
findAlbums(albu msDescryption, currentAlbum, showPhoto,isNew Album);
}
// FIN DEL COMBOBOX ///////////////////////////////////////////////////////////////////////////////////////////
function findAlbums(albu msDescryption, currentAlbum, showPhoto,isNew Album) {
//trace(albumsDes cryption.childr en().length());
for (var ui=0; ui<albumsDescry ption.children( ).length(); ui++) {
//trace ("looking for match: currentAlbum "+currentAl bum + " to " + albumsDescrypti on.children()[ui].attribute("nam e").toLowerCase ());
if (albumsDescrypt ion.children()[ui].attribute("nam e").toLowerCase () == currentAlbum.to LowerCase()) {
//trace("true");
foundAlbum = 1;
//trace ("-------------");
//find out where the images will be
//imgBase = albumsDescrypti on.childNodes[count02].attributes.ima gebase;
//trace ("imagebase is "+imgBase);
var photoPage = albumsDescrypti on.children()[ui];
var numPhotos = photoPage.child ren().length();
break;
}
}
//trace(photoPage );
displayPhoto(ph otoPage, numPhotos)
}
function displayPhoto(ph otoPage, numPhotos) {
var fotonu = photoPage.child ren().children( ).attribute("sr c").length() ;
var titulo:XMLList = photoPage.child ren().children( ).attribute("ti tle");
var fuente:XMLList = photoPage.child ren().children( ).attribute("sr c");
var desc:XMLList = photoPage.child ren().children( ).attribute("ca ption");
/*for (var a:int=0; a<titulo.length (); a++){
//trace ("ITEM "+a+"==> "+titulo[a]);
}
for (var e:int=0; e<fuente.length (); e++){
var imagesourcefile :String = fuente[e];
//trace ("ITEM "+e+"==> "+fuente[e]);
}
for (var i:int=0; i<desc.length() ; i++){
//trace ("ITEM "+i+"==> "+desc[i]);
}*/
fwdButton.addEv entListener(Mou seEvent.CLICK, nextImage);
bkButton.addEve ntListener(Mous eEvent.CLICK, prevImage);
var p = 0;
firstImage();
function firstImage() {
var albumHolder:Loa der = new Loader();
var url:String = "quat_admin/images/gallery/"+fuente[0]
var urlReq:URLReque st = new URLRequest(url) ;
albumHolder.loa d(urlReq);
conte.addChild( albumHolder);
des.photoCaptio nInfo.text = desc[0];
photoTitleInfo. text = titulo[0];
var sentido = 30;
filtros(sentido );
picture_num();
}
var myInterval;
function nextImage(event :MouseEvent){
trace("FUNCTION START---> p: "+p);
conte.x = -52
var fotonu = photoPage.child ren().children( ).attribute("sr c").length() ;
p++
p %= fotonu;
var albumHolder:Loa der = new Loader();
var url:String = "quat_admin/images/gallery/"+fuente[p]
var urlReq:URLReque st = new URLRequest(url) ;
albumHolder.loa d(urlReq);
conte.addChild( albumHolder);
des.photoCaptio nInfo.text = desc[p];
photoTitleInfo. text = titulo[p];
var sentido = 30;
trace("END OF FUNCTION-----------------> P: "+p);
filtros(sentido );
picture_num();
clearInterval(m yInterval);
}
function prevImage(event :MouseEvent){
conte.x = -52
var fotonu = photoPage.child ren().children( ).attribute("sr c").length() ;
clearInterval(m yInterval);
if (p>0) {
p--;
} else {
p = fotonu-1;
}
var albumHolder:Loa der = new Loader();
var url:String = "quat_admin/images/gallery/"+fuente[p]
var urlReq:URLReque st = new URLRequest(url) ;
albumHolder.loa d(urlReq);
conte.addChild( albumHolder);
des.photoCaptio nInfo.text = desc[p];
photoTitleInfo. text = titulo[p];
var sentido = -131;
filtros(sentido );
picture_num();
}
function picture_num() {
var fotonu = photoPage.child ren().children( ).attribute("sr c").length() ;
var current_pos = p+1;
//trace("foto cant: "+ fotonu+"fotos actual: "+current_p os+" la P:"+p);
pos_txt.text = current_pos+" / "+fotonu;
}
function filtros (sentido){
var myTween:Tween = new Tween(conte, "blur", Elastic.easeInO ut, 20, 0, 20, false);
myTween.addEven tListener(Tween Event.MOTION_CH ANGE, handleReset);
function handleReset(e:T weenEvent):void {
conte.filters = [new BlurFilter(cont e.blur, conte.blur, 1)];
}
var xPosT:Tween = new Tween(conte, "x", Regular.easeInO ut, -52, sentido, 3, true);
xPosT.addEventL istener(TweenEv ent.MOTION_CHAN GE, marcador);
function marcador(e:Twee nEvent):void {
var val = Math.round(cont e.x);
pos.text = val;
}
}
}
}[/HTML]