Pb with a class loading fotos
hello,
here little , simple class charged of loading 2 fotos in parent clip called "diaporama" (i expect 2nd foto set 20px on right of first 1 , above it)
you can test saving 2 fotos called foto1.jpg , foto2.jpg current directory containing swf file.
in .fla file put diapo.main() launch program.
class diapo {
//clip containing th fotos
private static var diaporama:movieclip;
//foto id
private var id:number;
//clip containing loaded foto
private var diapo:movieclip;
private var chargeur:moviecliploader;
//constructor
private function diapo(id:number) {
this.chargeur = new moviecliploader();
this.id = id;
this.diapo = diaporama.createemptymovieclip("diapo", id);
this.diapo._x = (this.id-1)*20;
this.chargeur.addlistener(this);
this.chargeur.loadclip("foto"+this.id+".jpg", diapo);
}
//main function chaged of displaying 3 fotos
public static function main() {
diaporama = _root.createemptymovieclip("diaporama", 1);
diaporama._x = 150;
diaporama._y = 200;
new diapo(1);
new diapo(2);
}
private function onloadinit() {
trace("ok");
}
}
my problem : when launch it, displays second foto, "ok" appears once while expected appear twice.
it seems load 1 foto (the last one). why?
thansk help,
pascal
here little , simple class charged of loading 2 fotos in parent clip called "diaporama" (i expect 2nd foto set 20px on right of first 1 , above it)
you can test saving 2 fotos called foto1.jpg , foto2.jpg current directory containing swf file.
in .fla file put diapo.main() launch program.
class diapo {
//clip containing th fotos
private static var diaporama:movieclip;
//foto id
private var id:number;
//clip containing loaded foto
private var diapo:movieclip;
private var chargeur:moviecliploader;
//constructor
private function diapo(id:number) {
this.chargeur = new moviecliploader();
this.id = id;
this.diapo = diaporama.createemptymovieclip("diapo", id);
this.diapo._x = (this.id-1)*20;
this.chargeur.addlistener(this);
this.chargeur.loadclip("foto"+this.id+".jpg", diapo);
}
//main function chaged of displaying 3 fotos
public static function main() {
diaporama = _root.createemptymovieclip("diaporama", 1);
diaporama._x = 150;
diaporama._y = 200;
new diapo(1);
new diapo(2);
}
private function onloadinit() {
trace("ok");
}
}
my problem : when launch it, displays second foto, "ok" appears once while expected appear twice.
it seems load 1 foto (the last one). why?
thansk help,
pascal
hi pascal,
evry new clip make via createemptymovieclip gets same name, , therefor replaces last 1 (even if asign them new depth, do).
so change:
this.diapo = diaporama.createemptymovieclip("diapo", id);
to:
this.diapo = diaporama.createemptymovieclip("diapo"+id, id);
evry new clip make via createemptymovieclip gets same name, , therefor replaces last 1 (even if asign them new depth, do).
so change:
this.diapo = diaporama.createemptymovieclip("diapo", id);
to:
this.diapo = diaporama.createemptymovieclip("diapo"+id, id);
More discussions in Adobe Animate CC - General
adobe
Comments
Post a Comment