/***************************************/ /*** SIMPLE SLIDE IMG - Action Script */ /*** 30/05/2007 - by Rempox Code */ /***************************************/ /* Questo codice è stato scritto per un utente del Forum HTML.it ipotizza che le immagini sia di un formato quadrato, che vengano lette e caricate nello slide tramite un file TXT denominato filedati.txt e che il suo formato sia ad esempio: &path=smiles/& &Foto1=smile1.jpg& &Foto2=smile2.jpg& &Foto3=smile3.jpg& &Foto4=smile4.jpg& &Foto5=smile5.jpg& &Foto6=smile6.jpg& &Foto7=smile7.jpg& &Foto8=smile8.jpg& &Foto9=smile9.jpg& Le foto devono essere caricate nella directory indicata nella variabile path=smiles/ che può essere cambiata a piacere Il codice prevede uno slide in automatico con sovrapposizione di immagini in Fade In, con un tempo di slide ogni 5 secondi. Prevede un pulsante STOP, PLAY ed uno switch di testo se mandare lo slide in LOOP o meno. Non avete bisogno di altro che caricare questo codice e giocarci un po l'esempio è presso: www.rempox.it/forum/slideimg/slide_AS.html Buon lavoro. Rempox */ //Definizione di un Formato testo personalizzato testoFormat = new TextFormat() testoFormat.font="_sans" testoFormat.size=11 testoFormat.bold=true testoFormat.color="0xF2F2F2" // supponiamo che le foto abbiamo tutte una stessa dimensione, così semplifichiamo la cosa // Settaggio Iniziale fotoW=200 // larghezza fotoH=200 // altezza foto_array= new Array() // metodo per la lettura di file esterni fotografie = new LoadVars() fotografie.onLoad=function(caricate){ if(caricate){ I=1 while(this["Foto"+I]!=undefined){ foto_array[I] = this.path+this["Foto"+I] I++ } create_structure() }else{ trace("file dati non trovato") } } fotografie.load("filedati.txt") // funzione di creazione della struttura // container 210 x 210 // box Info // btn Stop // btn Play // btn Loop // btn Prev // btn Next function create_structure(){ // creo container this.createEmptyMovieClip("container",this.getNextHighestDepth()) with (container) { lineStyle(2, "0x333333", 100); beginFill("0xf2f2f2", 100); moveTo(0, 0); lineTo(210, 0); lineTo(210, 210); lineTo(0, 210); lineTo(0, 0); endFill(); } container._x = (Stage.width- fotoW)/2 container._y = (Stage.height - fotoH)/2 // creo _Stop _Play, _Info, _Loop, _Prev e _Next this.createEmptyMovieClip("_Stop",this.getNextHighestDepth()) with (_Stop) { lineStyle(2, "0xf333333", 100); beginFill("0x336699", 100); moveTo(0, 0); lineTo(52.5, 0); lineTo(52.5, 20); lineTo(0, 20); lineTo(0, 0); endFill(); } _Stop._x = container._x _Stop._y = container._y + container._height-2 _Stop.createTextField("opzione",1,0,0,50,20) _Stop.opzione.selectable=false _Stop.opzione.text="STOP" _Stop.opzione.autoSize="Center" _Stop.opzione.setTextFormat(testoFormat) this.createEmptyMovieClip("_Play",this.getNextHighestDepth()) with (_Play) { lineStyle(2, "0x333333", 100); beginFill("0x336699", 100); moveTo(0, 0); lineTo(52.5, 0); lineTo(52.5, 20); lineTo(0, 20); lineTo(0, 0); endFill(); } _Play._x = container._x+_Stop._width-2 _Play._y = container._y + container._height-2 _Play.createTextField("opzione",1,0,0,50,20) _Play.opzione.selectable=false _Play.opzione.text="PLAY" _Play.opzione.autoSize="Center" _Play.opzione.setTextFormat(testoFormat) this.createEmptyMovieClip("_Loop",this.getNextHighestDepth()) with (_Loop) { lineStyle(2, "0x333333", 100); beginFill("0x336699", 100); moveTo(0, 0); lineTo(105, 0); lineTo(105, 20); lineTo(0, 20); lineTo(0, 0); endFill(); } _Loop._x = (container._x+_Stop._width-2+_Play._width)-2 _Loop._y = container._y + container._height-2 _Loop.createTextField("opzione",1,0,0,105,20) _Loop.opzione.selectable=false _Loop.opzione.text="Loop Slide = Si" _Loop.opzione.autoSize="Right" _Loop.opzione.setTextFormat(testoFormat) _Loop.stato = true this.createEmptyMovieClip("_Info",this.getNextHighestDepth()) with (_Info) { lineStyle(2, "0x333333", 100); beginFill("0x336699", 100); moveTo(0, 0); lineTo(210, 0); lineTo(210, 20); lineTo(0, 20); lineTo(0, 0); endFill(); } _Info._x = container._x _Info._y = container._y - _Info._height+2 _Info.createTextField("opzione",1,0,0,210,20) _Info.opzione.selectable=false /********************************************************/ // AVANTI E DIETRO this.createEmptyMovieClip("_Prev",this.getNextHighestDepth()) with (_Prev) { lineStyle(2, "0x333333", 100); beginFill("0x336699", 100); moveTo(0, 0); lineTo(105, 0); lineTo(105, 20); lineTo(0, 20); lineTo(0, 0); endFill(); } _Prev._x = container._x _Prev._y = _Stop._y + _Stop._height - 2 _Prev.createTextField("opzione",1,0,0,105,20) _Prev.opzione.selectable=false _Prev.opzione.text="REW" _Prev.opzione.autoSize="Center" _Prev.opzione.setTextFormat(testoFormat) this.createEmptyMovieClip("_Next",this.getNextHighestDepth()) with (_Next) { lineStyle(2, "0x333333", 100); beginFill("0x336699", 100); moveTo(0, 0); lineTo(105, 0); lineTo(105, 20); lineTo(0, 20); lineTo(0, 0); endFill(); } _Next._x = _Prev._x+_Prev._width-2 _Next._y = _Stop._y + _Stop._height - 2 _Next.createTextField("opzione",1,0,0,105,20) _Next.opzione.selectable=false _Next.opzione.text="FFW" _Next.opzione.autoSize="Center" _Next.opzione.setTextFormat(testoFormat) /********************************************************/ // AS per BOTTONI _Stop.onPress=function(){ avanza=false clearInterval(id) } _Play.onPress=function(){ avanza=true if(Index == foto_array.length-1){ Index=0 } start_slide() } _Loop.onPress=function(){ this.stato =! this.stato if(this.stato){ this.opzione.text="Loop Slide = Si" }else{ this.opzione.text="Loop Slide = No" } this.opzione.autoSize="Right" this.opzione.setTextFormat(testoFormat) } _Prev.onPress=function(){ avanza=false clearInterval(id) trace(Index) if(Index==1){ Index=foto_array.length } if(Index >1){ Index-=2 } start_slide() this.enabled=false } _Next.onPress=function(){ avanza=false clearInterval(id) trace(Index) if(Index==foto_array.length-1){ Index=0 } start_slide() this.enabled=false } container.createEmptyMovieClip("sotto",1) container.sotto._x=(container._width - fotoW)/2 container.sotto._y=(container._height - fotoH)/2 container.createEmptyMovieClip("sopra",2) container.sopra._x=(container._width - fotoW)/2 container.sopra._y=(container._height - fotoH)/2 start_slide() } Index=0 avanza=true function start_slide(){ if(Index <= foto_array.length-1){ Index++ _Info.opzione.text="Total IMG: "+(foto_array.length-1) + " - Actual: "+Index+"/"+(foto_array.length-1)+" Time Slide: 5\"" _Info.opzione.autoSize="Center" _Info.opzione.setTextFormat(testoFormat) container.sopra.loadMovie(foto_array[Index]) container.sopra._alpha=0 container.foto = foto_array[Index] container.onEnterFrame=function(){ car=this.sopra.getBytesTotal() tot=this.sopra.getBytesTotal() if(car == tot && car >=1024){ // caricata foto this.sopra._width = 200 this.sopra._height = 200 this.sopra.onEnterFrame=function(){ if(this._alpha<100){ this._alpha+=10 }else{ //trace(container.foto) container.sotto.loadMovie(container.foto) car1=container.sotto.getBytesTotal() tot1=container.sotto.getBytesTotal() if(car1 == tot1 && car1 > 1024){ // caricata foto container.sotto._width = 200 container.sotto._height = 200 _Next.enabled=true _Prev.enabled=true if(avanza){ id = setInterval(conta,5000) } delete this.onEnterFrame } } } delete this.onEnterFrame } } } } function conta(){ trace("sono passati 5 secondi") clearInterval(id) if(_Loop.stato){ if(Index == foto_array.length-1){ Index=0 } } start_slide() }