Salve a tutti,
vi illustro il mio problema.
Vorrei richiamare delle didascalie da un file xml a un sito fatto in flash.
Qual'è la striscia di codice che devo inserire e dove la devo inserire?
E' per un esame, grazie in anticipo!!
Vi incollo il mio codice:
fscommand("fullscreen", "true");
stage.scaleMode="noScale";
stage.align="TL";
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.Event;
//
//
var portfolio:XML;
var fileXML:URLRequest=new URLRequest("finto_database.xml");
var loader:URLLoader= new URLLoader(fileXML);
loader.load(fileXML);
loader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event):void{
portfolio=XML(loader.data);
var nGallery=portfolio.children().length();
creaMenu(nGallery)
}
function creaMenu(album):void{
for(var n:Number=0; n<album; n++){
var ptGal:Tasto=new Tasto();
menu.addChild(ptGal)
ptGal.testo.text=portfolio.children()[n].@nome.toUpperCase();
ptGal.x=160*n;
ptGal.indice=n;
ptGal.addEventListener (MouseEvent.CLICK, creaAnteprime);
}
}
var nAnteprime:uint;
function creaAnteprime (event:MouseEvent): void{
anteprime.visible=true;
var album=event.target.parent["indice"];
var nFoto=portfolio.children()[event.target.parent["indice"]].children().length();
//nAnteprime=k;
if (anteprime.numChildren!=0){// proprietà + semplice rispetto a: //(nAnteprime != 0){ //se nn ho effettuato u'anteprima prima è uguale a 0 se valore 0 nn è stato avviato il ciclo cmq fa la funz se diversa da 0
for (var n:uint=anteprime.numChildren; n>0; n--){
anteprime.removeChildAt(n-1);//rimuove i figli al num di indice indicato tra parentesi - n-1 xkè solito discorso la prima ha valore 0 la 2 ha valore 1.... quindi faccio 2, 1, 0 al posto di 321 visto ke il 3 nn esiste(in questo caso xkè sn 2)
anteprime.x=30;
}
}
for(var k:Number=0; k<nFoto; k++){ //creare antemprime
var thumb:Anteprima=new Anteprima();
anteprime.addChild(thumb)
thumb.x=234*k;
thumb.foto=portfolio.children()[album].children()[k].children();
var file:URLRequest=new URLRequest (portfolio.children()[album].children()[k].@anteprima);
var loader:Loader=new Loader();
loader.load(file);
thumb.img.addChild(loader);
thumb.addEventListener(MouseEvent.CLICK, caricaImg);
}
}
contImg.back.visible=false; //la x per chiudere ante
var ldrImg:Loader=new Loader();
function caricaImg (event:MouseEvent):void{
var file:URLRequest=new URLRequest(event.target.parent["foto"]);
ldrImg.load(file);
ldrImg.contentLoaderInfo.addEventListener(Event.CO MPLETE, imgCaricata);
contImg.back.visible=true;
}
function imgCaricata(event:Event):void{
contImg.addChild(ldrImg);
ldrImg.height=stage.stageHeight/2;
ldrImg.width=stage.stageHeight/2;
ldrImg.x=0-ldrImg.width/2;
ldrImg.y=0-ldrImg.height/2;
contImg.swapChildren(contImg.getChildAt(0), contImg.getChildAt(1));
contImg.back.x=ldrImg.width/2;
contImg.back.y=0-ldrImg.height/2;
}
function uncaricaImg (event:MouseEvent):void{ //chiudere anteprima big
contImg.removeChildAt(0);
contImg.back.visible=false;
}
contImg.back.addEventListener(MouseEvent.CLICK, uncaricaImg);
function scorriA (event:MouseEvent):void{
//if (anteprime.x>-672) {
if (anteprime.width>stage.stageWidth && anteprime.hitTestPoint (stage.stageWidth-10, stage.stageHeight/2)) {
anteprime.x-=234;
}
}
frecciaDx.addEventListener(MouseEvent.CLICK, scorriA);
function scorriB (event:MouseEvent):void{
if (anteprime.x<30) {
anteprime.x+=234;
}
}
frecciaSx.addEventListener(MouseEvent.CLICK, scorriB);
//
//
header.width=stage.stageWidth;
footer.width=stage.stageWidth;
gruppoAbout.y=stage.stageHeight/2
homeImg.x=stage.stageWidth/2;
homeImg.y=stage.stageHeight/2;
miniMenu2.y=stage.stageHeight-60;
miniMenu.y=stage.stageHeight-60;
frecciaDx.x=stage.stageWidth/2+40;
frecciaSx.x=stage.stageWidth/2-40;
contImg.x=stage.stageWidth/2;
contImg.y=stage.stageHeight/2;
anteprime.y=stage.stageHeight/2-99;
ldrImg.height=stage.stageHeight/2;
ldrImg.width=stage.stageHeight/2;
function rilevaGen (event:Event):void{
header.width=stage.stageWidth;
footer.width=stage.stageWidth;
footer.y=stage.stageHeight;
copyR.x=stage.stageWidth-10;
copyR.y=stage.stageHeight-10;
gruppoAbout.y=stage.stageHeight/2
homeImg.x=stage.stageWidth/2;
homeImg.y=stage.stageHeight/2;
miniMenu2.y=stage.stageHeight-60;
miniMenu.y=stage.stageHeight-60;
frecciaDx.x=stage.stageWidth/2+40;
frecciaSx.x=stage.stageWidth/2-40;
contImg.x=stage.stageWidth/2;
contImg.y=stage.stageHeight/2;
anteprime.y=stage.stageHeight/2-99;
ldrImg.height=stage.stageHeight/2;
ldrImg.width=stage.stageHeight/2;
}
stage.addEventListener(Event.RESIZE, rilevaGen);10

Rispondi quotando