bonjour,,
je me permet de poster car j'ai quelques problemes au niveau du dechargement d'un fichier swf contenant une video ()
j'ai suivi le tutorial de Republic of code >> http://www.republicofcode.com/tutorials/flash/as3gridgallery/
je l'ai ensuite adapté pr qu'il puisse charger des swf en lieu et place des images (dans le dossier full_images )
pb: lors d'un click sur la zone prevue a cet effet,je retourne sur ma " page " avec ma grid gallery , mais la video contenu dans le swf precedement chargé ne se decharge pas ()
en conaitriez vous par hazard la raison ?
>j'ai egalament testé le coup du dispatch event ,mais rien n'y fait ()
merci de votre lecture et de vos réponses si l'un d entre vous en connait une (voire plus ; p )
Sur ce,bonne continuation et bonne chance a tous les codeurs AS3 ....
code du FLA principal (contenant la grid gallery )
import fl.controls.ProgressBar;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
var columns:Number;
var my_x:Number;
var my_y:Number;
var my_thumb_width:Number;
var my_thumb_height:Number;
var my_images:XMLList;
var my_total:Number;
var container_mc:MovieClip;
var preloaders_mc:MovieClip;
var full_mc:MovieClip;
var x_counter:Number = 0;
var y_counter:Number = 0;
var my_tweens:Array = [];
var container_mc_tween:Tween;
var full_tween:Tween;
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("galleryBatch.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
var myXML:XML = new XML(e.target.data);
columns = myXML.@COLUMNS;
my_x = myXML.@XPOSITION;
my_y = myXML.@YPOSITION;
my_thumb_width = myXML.@WIDTH;
my_thumb_height = myXML.@HEIGHT;
my_images = myXML.IMAGE;
my_total = my_images.length();
createContainer();
callThumbs();
myXMLLoader.removeEventListener(Event.COMPLETE, processXML);
myXMLLoader = null;
}
function createContainer():void {
container_mc = new MovieClip();
container_mc.x = my_x;
container_mc.y = my_y;
addChild(container_mc);
container_mc.addEventListener(MouseEvent.CLICK, callFull);
container_mc.addEventListener(MouseEvent.MOUSE_OVER, onOver);
container_mc.addEventListener(MouseEvent.MOUSE_OUT, onOut);
container_mc.buttonMode = true;
preloaders_mc = new MovieClip();
preloaders_mc.x = container_mc.x;
preloaders_mc.y = container_mc.y;
//addChild(preloaders_mc);
}
//ancienne fonction de la grid gallerie
/*function callThumbs():void {
for (var i:Number = 0; i < my_total; i++) {
var thumb_url = my_images.@THUMB;
var thumb_loader = new Loader();
thumb_loader.load(new URLRequest(thumb_url));
thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
thumb_loader.name = i;
thumb_loader.x = (my_thumb_width+10)*x_counter;
thumb_loader.y = (my_thumb_height+10)*y_counter;
if (x_counter+1 < columns) {
x_counter++;
} else {
x_counter = 0;
y_counter++;
}
var preloader_pb:ProgressBar = new ProgressBar();
preloader_pb.source = thumb_loader.contentLoaderInfo;
preloader_pb.x = thumb_loader.x;
preloader_pb.y = thumb_loader.y;
preloader_pb.width = my_thumb_width;
preloader_pb.height = my_thumb_height;
preloaders_mc.addChild(preloader_pb);
preloader_pb.addEventListener(Event.COMPLETE, donePb);
}
}*/
///nouvelle gallerie avec le code de flo
function callThumbs():void {
for (var i:Number = 0; i < my_total; i++) {
//On vérifie que le "carré" à afficher ne soit pas positionné à l'endroit du swf "main"
if(i<18 || i>62 || (i%9)<2 || (i%9)>6){
var thumb_url = my_images.@THUMB;
var thumb_loader = new Loader();
thumb_loader.load(new URLRequest(thumb_url));
thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
thumb_loader.name = i;
thumb_loader.x = (my_thumb_width+10)*x_counter;
thumb_loader.y = (my_thumb_height+10)*y_counter;
if (x_counter+1 < columns) {
x_counter++;
} else {
x_counter = 0;
y_counter++;
}
var preloader_pb:ProgressBar = new ProgressBar();
preloader_pb.source = thumb_loader.contentLoaderInfo;
preloader_pb.x = thumb_loader.x;
preloader_pb.y = thumb_loader.y;
preloader_pb.width = my_thumb_width;
preloader_pb.height = my_thumb_height;
preloaders_mc.addChild(preloader_pb);
preloader_pb.addEventListener(Event.COMPLETE, donePb);
}
else //Sinon on ne génère rien
{
//Mise à jour des indices x et y
if (x_counter+1 < columns) {
x_counter++;
} else {
x_counter = 0;
y_counter++;
}
}
}
}
function thumbLoaded(e:Event):void {
var my_thumb:Loader = Loader(e.target.loader);
container_mc.addChild(my_thumb);
my_tweens[Number(my_thumb.name)]=new Tween(my_thumb, "alpha", Strong.easeIn, 0,1,0.5, true);
my_thumb.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded);
}
function callFull(e:MouseEvent):void {
var full_loader:Loader = new Loader();
var full_url = my_images[e.target.name].@FULL;
full_loader.load(new URLRequest(full_url));
full_loader.contentLoaderInfo.addEventListener(Event.INIT, fullLoaded);
var full_pb:ProgressBar = new ProgressBar();
full_pb.source = full_loader.contentLoaderInfo;
full_pb.x = (stage.stageWidth - full_pb.width)/2;
full_pb.y = (stage.stageHeight - full_pb.height)/2;
preloaders_mc.addChild(full_pb);
full_pb.addEventListener(Event.COMPLETE, donePb);
container_mc.removeEventListener(MouseEvent.CLICK, callFull);
container_mc.buttonMode = false;
container_mc.removeEventListener(MouseEvent.MOUSE_OVER, onOver);
container_mc.removeEventListener(MouseEvent.MOUSE_OUT, onOut);
//la ligne suivante change la transparence lors du tween
container_mc_tween = new Tween(container_mc, "alpha", Regular.easeOut, 1,0,2, true);
}
function fullLoaded(e:Event):void {
full_mc = new MovieClip();
//je change la ligne ci dessous
//full_mc.buttonMode = true;
addChild(full_mc);
var my_loader:Loader = Loader(e.target.loader);
full_mc.addChild(my_loader);
full_tween = new Tween(my_loader, "alpha", Strong.easeIn, 0,1,2, true);
//on repositionne plus ou moins le contenu chargé
my_loader.x = (stage.stageWidth - my_loader.width)/2;
// ORIGINAL > my_loader.y = (stage.stageHeight - my_loader.height)/2;
my_loader.y = ((stage.stageHeight - my_loader.height)/2) - 10;
my_loader.addEventListener(MouseEvent.CLICK,removeFull);
my_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, fullLoaded);
}
/////old one /////
/*function removeFull(e:MouseEvent):void {
var my_loader:Loader = Loader (e.currentTarget);
full_tween = new Tween(my_loader, "alpha", Strong.easeOut, 1,0,2, true);
full_tween.addEventListener(TweenEvent.MOTION_FINISH, tweenFinished);
//la ligne suivante change la transparence lors du tween
container_mc_tween = new Tween(container_mc, "alpha", Regular.easeIn, 0,1,2, true);
}
*/
function removeFull(e:MouseEvent):void {
//Vérifie si on clique en dehors de la vidéo
//if(e.localX>240 && e.localY<440){ //On ne fait rien (on est dans la zone video)
//if(e.localX>270 || e.localY>50){ //On ne fait rien (on est hors du bouton RETOUR)
if(e.stageX>530 || e.stageY>200){
trace(e.localX+","+e.localY);
}
else //Sinon on décharge
{
var my_loader:Loader = Loader (e.currentTarget);
full_tween = new Tween(my_loader, "alpha", Strong.easeOut, 1,0,2, true);
full_tween.addEventListener(TweenEvent.MOTION_FINISH, tweenFinished);
//la ligne suivante change la transparence lors du tween
container_mc_tween = new Tween(container_mc, "alpha", Regular.easeIn, 0,1,2, true);
}
}
function donePb(e:Event):void {
var my_pb:ProgressBar = ProgressBar(e.target);
preloaders_mc.removeChild(my_pb);
my_pb.removeEventListener(Event.COMPLETE, donePb);
}
function tweenFinished(e:TweenEvent):void {
var my_loader:Loader = Loader (e.target.obj);
my_loader.unload();
full_mc.removeChild(my_loader);// This line was removeChid(my_loader), just add full_mc before it.
removeChild(full_mc);
full_mc = null;
container_mc.addEventListener(MouseEvent.CLICK, callFull);
container_mc.buttonMode = true;
container_mc.addEventListener(MouseEvent.MOUSE_OVER, onOver);
container_mc.addEventListener(MouseEvent.MOUSE_OUT, onOut);
var my_tween:Tween = Tween(e.target);
my_tween.removeEventListener(TweenEvent.MOTION_FINISH, tweenFinished);
}
function onOver(e:MouseEvent):void {
var my_thumb:Loader = Loader(e.target);
my_thumb.alpha = 0.5;
}
function onOut(e:MouseEvent):void {
var my_thumb:Loader = Loader (e.target);
my_thumb.alpha = 1;
}
///cousineries //////
/*function removeFull(e:MouseEvent):void {
//Vérifie si on clique en dehors de la vidéo
//if(e.localX>240 && e.localY<440){ //On ne fait rien (on est dans la zone video)
if(e.localX>270 || e.localY>50){ //On ne fait rien (on est hors du bouton RETOUR)
trace(e.localX+","+e.localY);
}
else //Sinon on décharge
{
var my_loader:Loader = Loader (e.currentTarget);
full_tween = new Tween(my_loader, "alpha", Strong.easeOut, 1,0,2, true);
full_tween.addEventListener(TweenEvent.MOTION_FINISH, tweenFinished);
//la ligne suivante change la transparence lors du tween
container_mc_tween = new Tween(container_mc, "alpha", Regular.easeIn, 0,1,2, true);
}
}*/
/////////////////////loader du " CARRE du CARRE " /////////////////////////
var carreDuCarreLoader:Loader = new Loader();
carreDuCarreLoader.x = 420;
carreDuCarreLoader.y = 320;
carreDuCarreLoader.load(new URLRequest("carreDuCarre.swf"));
trace ("carre du carre chargé " );
addChild(carreDuCarreLoader);
setChildIndex(carreDuCarreLoader,this.numChildren-1);
je me permet de poster car j'ai quelques problemes au niveau du dechargement d'un fichier swf contenant une video ()
j'ai suivi le tutorial de Republic of code >> http://www.republicofcode.com/tutorials/flash/as3gridgallery/
je l'ai ensuite adapté pr qu'il puisse charger des swf en lieu et place des images (dans le dossier full_images )
pb: lors d'un click sur la zone prevue a cet effet,je retourne sur ma " page " avec ma grid gallery , mais la video contenu dans le swf precedement chargé ne se decharge pas ()
en conaitriez vous par hazard la raison ?
>j'ai egalament testé le coup du dispatch event ,mais rien n'y fait ()
merci de votre lecture et de vos réponses si l'un d entre vous en connait une (voire plus ; p )
Sur ce,bonne continuation et bonne chance a tous les codeurs AS3 ....
code du FLA principal (contenant la grid gallery )
import fl.controls.ProgressBar;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
var columns:Number;
var my_x:Number;
var my_y:Number;
var my_thumb_width:Number;
var my_thumb_height:Number;
var my_images:XMLList;
var my_total:Number;
var container_mc:MovieClip;
var preloaders_mc:MovieClip;
var full_mc:MovieClip;
var x_counter:Number = 0;
var y_counter:Number = 0;
var my_tweens:Array = [];
var container_mc_tween:Tween;
var full_tween:Tween;
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("galleryBatch.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
var myXML:XML = new XML(e.target.data);
columns = myXML.@COLUMNS;
my_x = myXML.@XPOSITION;
my_y = myXML.@YPOSITION;
my_thumb_width = myXML.@WIDTH;
my_thumb_height = myXML.@HEIGHT;
my_images = myXML.IMAGE;
my_total = my_images.length();
createContainer();
callThumbs();
myXMLLoader.removeEventListener(Event.COMPLETE, processXML);
myXMLLoader = null;
}
function createContainer():void {
container_mc = new MovieClip();
container_mc.x = my_x;
container_mc.y = my_y;
addChild(container_mc);
container_mc.addEventListener(MouseEvent.CLICK, callFull);
container_mc.addEventListener(MouseEvent.MOUSE_OVER, onOver);
container_mc.addEventListener(MouseEvent.MOUSE_OUT, onOut);
container_mc.buttonMode = true;
preloaders_mc = new MovieClip();
preloaders_mc.x = container_mc.x;
preloaders_mc.y = container_mc.y;
//addChild(preloaders_mc);
}
//ancienne fonction de la grid gallerie
/*function callThumbs():void {
for (var i:Number = 0; i < my_total; i++) {
var thumb_url = my_images.@THUMB;
var thumb_loader = new Loader();
thumb_loader.load(new URLRequest(thumb_url));
thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
thumb_loader.name = i;
thumb_loader.x = (my_thumb_width+10)*x_counter;
thumb_loader.y = (my_thumb_height+10)*y_counter;
if (x_counter+1 < columns) {
x_counter++;
} else {
x_counter = 0;
y_counter++;
}
var preloader_pb:ProgressBar = new ProgressBar();
preloader_pb.source = thumb_loader.contentLoaderInfo;
preloader_pb.x = thumb_loader.x;
preloader_pb.y = thumb_loader.y;
preloader_pb.width = my_thumb_width;
preloader_pb.height = my_thumb_height;
preloaders_mc.addChild(preloader_pb);
preloader_pb.addEventListener(Event.COMPLETE, donePb);
}
}*/
///nouvelle gallerie avec le code de flo
function callThumbs():void {
for (var i:Number = 0; i < my_total; i++) {
//On vérifie que le "carré" à afficher ne soit pas positionné à l'endroit du swf "main"
if(i<18 || i>62 || (i%9)<2 || (i%9)>6){
var thumb_url = my_images.@THUMB;
var thumb_loader = new Loader();
thumb_loader.load(new URLRequest(thumb_url));
thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
thumb_loader.name = i;
thumb_loader.x = (my_thumb_width+10)*x_counter;
thumb_loader.y = (my_thumb_height+10)*y_counter;
if (x_counter+1 < columns) {
x_counter++;
} else {
x_counter = 0;
y_counter++;
}
var preloader_pb:ProgressBar = new ProgressBar();
preloader_pb.source = thumb_loader.contentLoaderInfo;
preloader_pb.x = thumb_loader.x;
preloader_pb.y = thumb_loader.y;
preloader_pb.width = my_thumb_width;
preloader_pb.height = my_thumb_height;
preloaders_mc.addChild(preloader_pb);
preloader_pb.addEventListener(Event.COMPLETE, donePb);
}
else //Sinon on ne génère rien
{
//Mise à jour des indices x et y
if (x_counter+1 < columns) {
x_counter++;
} else {
x_counter = 0;
y_counter++;
}
}
}
}
function thumbLoaded(e:Event):void {
var my_thumb:Loader = Loader(e.target.loader);
container_mc.addChild(my_thumb);
my_tweens[Number(my_thumb.name)]=new Tween(my_thumb, "alpha", Strong.easeIn, 0,1,0.5, true);
my_thumb.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded);
}
function callFull(e:MouseEvent):void {
var full_loader:Loader = new Loader();
var full_url = my_images[e.target.name].@FULL;
full_loader.load(new URLRequest(full_url));
full_loader.contentLoaderInfo.addEventListener(Event.INIT, fullLoaded);
var full_pb:ProgressBar = new ProgressBar();
full_pb.source = full_loader.contentLoaderInfo;
full_pb.x = (stage.stageWidth - full_pb.width)/2;
full_pb.y = (stage.stageHeight - full_pb.height)/2;
preloaders_mc.addChild(full_pb);
full_pb.addEventListener(Event.COMPLETE, donePb);
container_mc.removeEventListener(MouseEvent.CLICK, callFull);
container_mc.buttonMode = false;
container_mc.removeEventListener(MouseEvent.MOUSE_OVER, onOver);
container_mc.removeEventListener(MouseEvent.MOUSE_OUT, onOut);
//la ligne suivante change la transparence lors du tween
container_mc_tween = new Tween(container_mc, "alpha", Regular.easeOut, 1,0,2, true);
}
function fullLoaded(e:Event):void {
full_mc = new MovieClip();
//je change la ligne ci dessous
//full_mc.buttonMode = true;
addChild(full_mc);
var my_loader:Loader = Loader(e.target.loader);
full_mc.addChild(my_loader);
full_tween = new Tween(my_loader, "alpha", Strong.easeIn, 0,1,2, true);
//on repositionne plus ou moins le contenu chargé
my_loader.x = (stage.stageWidth - my_loader.width)/2;
// ORIGINAL > my_loader.y = (stage.stageHeight - my_loader.height)/2;
my_loader.y = ((stage.stageHeight - my_loader.height)/2) - 10;
my_loader.addEventListener(MouseEvent.CLICK,removeFull);
my_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, fullLoaded);
}
/////old one /////
/*function removeFull(e:MouseEvent):void {
var my_loader:Loader = Loader (e.currentTarget);
full_tween = new Tween(my_loader, "alpha", Strong.easeOut, 1,0,2, true);
full_tween.addEventListener(TweenEvent.MOTION_FINISH, tweenFinished);
//la ligne suivante change la transparence lors du tween
container_mc_tween = new Tween(container_mc, "alpha", Regular.easeIn, 0,1,2, true);
}
*/
function removeFull(e:MouseEvent):void {
//Vérifie si on clique en dehors de la vidéo
//if(e.localX>240 && e.localY<440){ //On ne fait rien (on est dans la zone video)
//if(e.localX>270 || e.localY>50){ //On ne fait rien (on est hors du bouton RETOUR)
if(e.stageX>530 || e.stageY>200){
trace(e.localX+","+e.localY);
}
else //Sinon on décharge
{
var my_loader:Loader = Loader (e.currentTarget);
full_tween = new Tween(my_loader, "alpha", Strong.easeOut, 1,0,2, true);
full_tween.addEventListener(TweenEvent.MOTION_FINISH, tweenFinished);
//la ligne suivante change la transparence lors du tween
container_mc_tween = new Tween(container_mc, "alpha", Regular.easeIn, 0,1,2, true);
}
}
function donePb(e:Event):void {
var my_pb:ProgressBar = ProgressBar(e.target);
preloaders_mc.removeChild(my_pb);
my_pb.removeEventListener(Event.COMPLETE, donePb);
}
function tweenFinished(e:TweenEvent):void {
var my_loader:Loader = Loader (e.target.obj);
my_loader.unload();
full_mc.removeChild(my_loader);// This line was removeChid(my_loader), just add full_mc before it.
removeChild(full_mc);
full_mc = null;
container_mc.addEventListener(MouseEvent.CLICK, callFull);
container_mc.buttonMode = true;
container_mc.addEventListener(MouseEvent.MOUSE_OVER, onOver);
container_mc.addEventListener(MouseEvent.MOUSE_OUT, onOut);
var my_tween:Tween = Tween(e.target);
my_tween.removeEventListener(TweenEvent.MOTION_FINISH, tweenFinished);
}
function onOver(e:MouseEvent):void {
var my_thumb:Loader = Loader(e.target);
my_thumb.alpha = 0.5;
}
function onOut(e:MouseEvent):void {
var my_thumb:Loader = Loader (e.target);
my_thumb.alpha = 1;
}
///cousineries //////
/*function removeFull(e:MouseEvent):void {
//Vérifie si on clique en dehors de la vidéo
//if(e.localX>240 && e.localY<440){ //On ne fait rien (on est dans la zone video)
if(e.localX>270 || e.localY>50){ //On ne fait rien (on est hors du bouton RETOUR)
trace(e.localX+","+e.localY);
}
else //Sinon on décharge
{
var my_loader:Loader = Loader (e.currentTarget);
full_tween = new Tween(my_loader, "alpha", Strong.easeOut, 1,0,2, true);
full_tween.addEventListener(TweenEvent.MOTION_FINISH, tweenFinished);
//la ligne suivante change la transparence lors du tween
container_mc_tween = new Tween(container_mc, "alpha", Regular.easeIn, 0,1,2, true);
}
}*/
/////////////////////loader du " CARRE du CARRE " /////////////////////////
var carreDuCarreLoader:Loader = new Loader();
carreDuCarreLoader.x = 420;
carreDuCarreLoader.y = 320;
carreDuCarreLoader.load(new URLRequest("carreDuCarre.swf"));
trace ("carre du carre chargé " );
addChild(carreDuCarreLoader);
setChildIndex(carreDuCarreLoader,this.numChildren-1);