var prom = new Promise.resolve();
words.forEach(v => {
prom = prom.then(() => {
return myCoolAnimation(v);
});
});
function myCoolAnimation(v) {
return new Promise((resolve, reject) => {
// Делаем все
el.onclick = () => { // пример, у Вас будет другое событие
// Доделали
resolve();
};
});
}
/**
* @param _url
*/
public function getVideoUrl(url:String):void
{
this.loader = new URLLoader;
this.loader.addEventListener(Event.COMPLETE, this.getVideoUrlComplite);
this.loader.load(new URLRequest(url));
}
/**
*
* @param e
*/
private function getVideoUrlComplite(e:Event):void
{
var page:String = e.target.data;
var finder:RegExp = /name=\"flashvars\"\s+value=\"(?P<flashvars>.*)\"/gi
var result:Array = finder.exec(page);
page = null;
var flashvars:String = (result.flashvars || "").replace(/\&\;/gi, '&');
var varUrl:URLVariables = new URLVariables(flashvars);
this._url = varUrl.url360;
// url240
// url360
// url480
// url720
this._ready = true;
this.ns.play(this._url);
this.loader.removeEventListener(Event.COMPLETE, this.getVideoUrlComplite);
}