1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| stop();
var chargeur:URLLoader = new URLLoader();
chargeur.addEventListener(Event.COMPLETE,finChargement);
chargeur.load(new URLRequest("ressources/xml/soustitres.xml"));
var soustitres:XML;
var chapitreActuel:XML;
var images:XML;
var son:XML;
var timerSousTitres:Timer;
var heureDebut:int;
var delai:int;
var numPhrase:int;
var conteneurSon:Sound = new Sound();
var canal:SoundChannel = new SoundChannel();
var tampon :SoundLoaderContext=new SoundLoaderContext(5000);
var sousTitrage = new soustitrage;
sousTitrage.y=680;
function finChargement(ev:Event) {
soustitres = new XML(ev.target.data);
images = new XML(ev.target.data);
liChapitre("phase_1");
}
function liChapitre(titre:String) {
numPhrase = 0;
chapitreActuel = soustitres.chapitre.(@id == titre)[0];
//trace(chapitreActuel);
if (numPhrase >= chapitreActuel.phrase.length()) {
return;
}
images = soustitres.chapitre.image[0];
var chargeurImage:Loader = new Loader();
addChild(chargeurImage);
chargeurImage.load(new URLRequest (images));
addChild(sousTitrage);
son = soustitres.chapitre.sons[0];
//trace(son)
var fichierSon:URLRequest = new URLRequest(son);
conteneurSon.load(fichierSon,tampon);
canal = conteneurSon.play();
var delai:int;
delai = chapitreActuel.phrase[numPhrase].@debut;
heureDebut = getTimer();
timerSousTitres = new Timer(delai,1);
timerSousTitres.addEventListener(TimerEvent.TIMER,afficheSousTitres);
timerSousTitres.start();
}
function afficheSousTitres(ev:TimerEvent) {
sousTitrage.st_txt.text = chapitreActuel.phrase[numPhrase];
var heureCourante:int = getTimer();
var delai:int = chapitreActuel.phrase[numPhrase].@fin*1000 - (heureCourante-heureDebut);
if (delai < 0) {
delai = 0;
}
timerSousTitres = new Timer(delai,1);
timerSousTitres.addEventListener(TimerEvent.TIMER,effaceSousTitres);
timerSousTitres.start();
}
function effaceSousTitres(ev:TimerEvent) {
sousTitrage.st_txt.text = "";
numPhrase++;
if (numPhrase >= chapitreActuel.phrase.length()) {
this.nextFrame();
return;
}
var heureCourante:int = getTimer();
var delai:int = chapitreActuel.phrase[numPhrase].@debut*1000 - (heureCourante-heureDebut);
if (delai < 0) delai = 0;
timerSousTitres = new Timer(delai,1);
timerSousTitres.addEventListener(TimerEvent.TIMER,afficheSousTitres);
timerSousTitres.start();
} |
Partager