1 Reply Latest reply on May 31, 2006 1:53 AM by Newsgroup_User

    Still need help about a preloader..

    Level 7
      Hi guys..

      I need some help to understand the preloader concept.
      Any code will be appreciated..
      Here's my needs.

      I have a page where I set a thumbnailer and a Zoom section.
      With this page, the user can navigate between different items
      and each item can have multiple pictures (loaded from an xml file).

      I would like to set up a preloader for the different images of the
      thumbnailer (but need to have only one preloader).
      Someone told me to put all the image onto a Mc and set the preloader to this
      mc.
      But frankly, I don't know how to do it with my configuration (Still
      newbie)....

      Here's a demo of my humble mockup
      http://www.netsunset.com/flash/demo.htm

      To see the thumbnailer you have to click on an item.
      By the way, you ll find my code for this part, and I would like to know if I
      could avoid to reload
      twice the same image.
      I do it for the thumbnailer and the Zoom.
      Is there a way to load the picture and duplicate it to the Zoom MC ?

      I thank you in advance for your help

      Stan
      here's the code.
      Also, if you think I can improve this code, you re welcome to tell what I
      have to change.




      btnCritere_btn.onRelease=function(){
      _parent.gotoAndPlay(2);
      }
      function effet_bouton():Void{
      this.gotoAndPlay(2);
      }

      var startScaleZoom:Number = 100;
      var endScaleZoom:Number= 699;
      var speedZoom:Number= 100;
      var mcl_obj bject = new Object();
      var currentZoom:MovieClip;
      var scrollx:Number=miniature_mc.ligne_mc._x;
      var scrollcompteur:Number=0;
      var strReference:String;
      var strTypebien:String;
      var strPrix:String;
      var strSurface:String;
      var strPieces:String;
      var strVille:String;
      var strDescriptif:String;
      var lesImages:Array;
      var bienxml:XML;
      var idbiencurrent:Number=0;
      var photoInitiale:Boolean;
      var arrID=_root.charte_mc.content_mc.acheter_mc.arrID;

      btnSuivant_mc.onRelease=navigation_fiche;
      btnPrecedent_mc.onRelease=navigation_fiche;
      btnPremier_mc.onRelease=navigation_fiche;
      btnDernier_mc.onRelease=navigation_fiche;
      btnPrecedent_mc.onRollOver =effet_bouton;
      btnSuivant_mc.onRollOver =effet_bouton;
      btnPremier_mc.onRollOver =effet_bouton;
      btnDernier_mc.onRollOver =effet_bouton;

      for (var i:Number = 0; i < arrID.length; i++) {
      if (arrID ==_root.charte_mc.content_mc.acheter_mc.idselection){
      chargeFiche(arrID
      );
      idbiencurrent=i;
      positionactuelle=idbiencurrent;
      }
      }

      function reinitialisation(fiche:Number):Void{
      var t:String;
      for (t in miniature_mc.ligne_mc){
      removeMovieClip(miniature_mc.ligne_mc[t]);
      }
      for (t in placePhoto_mc){
      removeMovieClip(placePhoto_mc[t]);
      }
      photoInitiale=false;
      miniature_mc.ligne_mc._x=0;
      scrollcompteur=0;
      scrollx=0;
      currentZoom=undefined;
      chargeFiche(fiche);
      }

      function chargeFiche(bienid:Number):Void{
      photoInitiale=false;
      strReference="";
      strTypebien="";
      strPrix="";
      strSurface="";
      strPieces="";
      strVille="";
      strDescriptif="";
      lesImages =new Array();
      bienxml = new XML();
      bienxml.ignoreWhite = true;
      bienxml.load(_root.urlFicheBien+"?bien_id="+bienid.toString());
      bienxml.onLoad = function(success:Boolean) {
      if (success) {
      var biennodes:Array = this.firstChild.childNodes;
      for (var ii:Number = 0; ii < biennodes.length; ii++) {
      if (biennodes[ii].nodeName.toLowerCase()=="offre"){
      strReference=biennodes[ii].attributes["id"];
      for (var i:Number = 0; i < biennodes[ii].childNodes.length; i++) {
      if (biennodes[ii].childNodes .nodeName.toLowerCase()=="typebien")
      strTypebien=biennodes[ii].childNodes
      .firstChild.nodeValue;
      if (biennodes[ii].childNodes .nodeName.toLowerCase()=="prix")
      strPrix=biennodes[ii].childNodes
      .firstChild.nodeValue;
      if (biennodes[ii].childNodes .nodeName.toLowerCase()=="surface")
      strSurface=biennodes[ii].childNodes
      .firstChild.nodeValue;
      if (biennodes[ii].childNodes .nodeName.toLowerCase()=="pieces")
      strPieces=biennodes[ii].childNodes
      .firstChild.nodeValue;
      if (biennodes[ii].childNodes .nodeName.toLowerCase()=="ville")
      strVille=biennodes[ii].childNodes
      .firstChild.nodeValue;
      if (biennodes[ii].childNodes .nodeName.toLowerCase()=="descriptif")
      strDescriptif=biennodes[ii].childNodes
      .firstChild.nodeValue;
      if (biennodes[ii].childNodes .nodeName.toLowerCase()=="photos") {
      for (var a:Number = 0; a <
      biennodes[ii].childNodes
      .childNodes.length; a++) {
      lesImages[a]=biennodes[ii].childNodes .childNodes[a].attributes["fichier"];
      }
      }
      }
      }
      }
      typebien_txt.text=strTypebien;
      prix_txt.text=strPrix;
      pieces_txt.text=strPieces;
      surface_txt.text=strSurface;
      ville_txt.text=strVille;
      reference_txt.text=strReference;
      descriptif_txt.text=strDescriptif;
      compteur_txt.text=(idbiencurrent+1).toString()+" /
      "+arrID.length.toString();
      affichage();
      } else {
      trace('erreur d\'acc�s au fichier XML');
      }
      }
      }
      function affichage():Void{
      var nomMc:String;
      for (var i:Number=0;i<lesImages.length;++i){
      nomMc="mini"+i+"_mc";
      miniature_mc.ligne_mc.attachMovie("vignette_clip",nomMc,i);
      miniature_mc.ligne_mc[nomMc]._x=34.5+(69*i);
      miniature_mc.ligne_mc[nomMc]._y=35;
      miniature_mc.ligne_mc[nomMc].onRelease=function(){
      var b:MovieClip = this.getZoom();
      ZoomPhoto(b);
      }
      placePhoto_mc.attachMovie("zoomMC","zoom"+i+"_mc",i);
      placePhoto_mc[nomMc]._visible=false;
      miniature_mc.ligne_mc[nomMc].setZoom(placePhoto_mc["zoom"+i+"_mc"]);
      miniature_mc.ligne_mc[nomMc].setNumero(i);
      var my_mcl:MovieClipLoader = new MovieClipLoader();
      my_mcl.addListener(mcl_obj)
      my_mcl.loadClip(lesImages
      ,miniature_mc.ligne_mc[nomMc].vignette_mc.emplacement_mc);
      my_mcl.loadClip(lesImages ,placePhoto_mc["zoom"+i+"_mc"].fgPhoto_mc);
      }
      if (lesImages.length>=5){
      scrollcompteur=5;
      }else{
      scrollcompteur=lesImages.length;
      }
      }


      mcl_obj.onLoadInit=function(target_mc:MovieClip):Void{
      if (target_mc._name.substr(0,7)=="fgPhoto"){
      if (target_mc._height>target_mc._width){
      target_mc._width=target_mc._width*(46/target_mc._height);
      target_mc._x+= (63-target_mc._width)/2;
      target_mc._height=46;
      if (!photoInitiale){
      ZoomPhoto(placePhoto_mc["zoom0_mc"]);
      photoInitiale=true;
      }
      }else{
      target_mc._height=target_mc._height*(63/target_mc._width);
      target_mc._width=63;
      if (!photoInitiale){
      ZoomPhoto(placePhoto_mc["zoom0_mc"]);
      photoInitiale=true;
      }
      }
      target_mc._x+=-32;
      target_mc._y+=-26;
      }else{
      if (target_mc._height>target_mc._width){
      target_mc._width=target_mc._width*(70/target_mc._height);
      target_mc._x+= (93-target_mc._width)/2;
      target_mc._height=70;
      }else{
      target_mc._height=target_mc._height*(93/target_mc._width);
      target_mc._width=93;
      }
      }
      }



      function ZoomPhoto(b:MovieClip){
      var b:MovieClip=b;
      b._visible=true;
      if (currentZoom._name!=b._name){
      swapDepths.call(b,10000);
      b._alpha=100;
      b.onEnterFrame = function () {
      if (b._xscale < endScaleZoom) {
      b._xscale += speedZoom;
      b._yscale += speedZoom;
      } else {
      b._xscale = endScaleZoom;
      b._yscale = endScaleZoom;
      if (currentZoom._name!=undefined){
      currentZoom._xscale = startScaleZoom;
      currentZoom._yscale = startScaleZoom;
      currentZoom._alpha=0;
      }
      currentZoom=b;
      delete b.onEnterFrame;
      }
      }
      }
      }





      function navigation_fiche():Void{
      if (arrID.length>0){
      var positionactuelle:Number=idbiencurrent;
      switch (this._name) {
      case "btnPrecedent_mc" :
      if (idbiencurrent>0) idbiencurrent-=1;
      break;
      case "btnPremier_mc" :
      if (idbiencurrent>0) idbiencurrent=0;
      break;
      case "btnDernier_mc" :
      if (idbiencurrent<arrID.length-1)idbiencurrent=arrID.length-1;
      break;
      case "btnSuivant_mc" :
      if (idbiencurrent<arrID.length-1)idbiencurrent+=1;
      break;
      }
      if (positionactuelle!=idbiencurrent)
      reinitialisation(arrID[idbiencurrent]);
      }
      }
      stop();


        • 1. Re: Still need help about a preloader..
          Level 7
          Hi!

          You might find some usefull help if you go to:
          http://www.gotoandlearn.com/

          In particular check out External SWF Preloading.

          Good luck!

          /Jensen/

          "Stan Sainte-Rose" <stan@pasdepam.netsunset.com> wrote in message
          news:e5jenf$ns4$1@forums.macromedia.com...
          > Hi guys..
          >
          > I need some help to understand the preloader concept.
          > Any code will be appreciated..
          > Here's my needs.
          >
          > I have a page where I set a thumbnailer and a Zoom section.
          > With this page, the user can navigate between different items
          > and each item can have multiple pictures (loaded from an xml file).
          >
          > I would like to set up a preloader for the different images of the
          > thumbnailer (but need to have only one preloader).
          > Someone told me to put all the image onto a Mc and set the preloader to
          > this mc.
          > But frankly, I don't know how to do it with my configuration (Still
          > newbie)....
          >
          > Here's a demo of my humble mockup
          > http://www.netsunset.com/flash/demo.htm
          >
          > To see the thumbnailer you have to click on an item.
          > By the way, you ll find my code for this part, and I would like to know if
          > I could avoid to reload
          > twice the same image.
          > I do it for the thumbnailer and the Zoom.
          > Is there a way to load the picture and duplicate it to the Zoom MC ?
          >
          > I thank you in advance for your help
          >
          > Stan
          > here's the code.
          > Also, if you think I can improve this code, you re welcome to tell what I
          > have to change.
          >
          >
          >
          >
          > btnCritere_btn.onRelease=function(){
          > _parent.gotoAndPlay(2);
          > }
          > function effet_bouton():Void{
          > this.gotoAndPlay(2);
          > }
          >
          > var startScaleZoom:Number = 100;
          > var endScaleZoom:Number= 699;
          > var speedZoom:Number= 100;
          > var mcl_obj bject = new Object();
          > var currentZoom:MovieClip;
          > var scrollx:Number=miniature_mc.ligne_mc._x;
          > var scrollcompteur:Number=0;
          > var strReference:String;
          > var strTypebien:String;
          > var strPrix:String;
          > var strSurface:String;
          > var strPieces:String;
          > var strVille:String;
          > var strDescriptif:String;
          > var lesImages:Array;
          > var bienxml:XML;
          > var idbiencurrent:Number=0;
          > var photoInitiale:Boolean;
          > var arrID=_root.charte_mc.content_mc.acheter_mc.arrID;
          >
          > btnSuivant_mc.onRelease=navigation_fiche;
          > btnPrecedent_mc.onRelease=navigation_fiche;
          > btnPremier_mc.onRelease=navigation_fiche;
          > btnDernier_mc.onRelease=navigation_fiche;
          > btnPrecedent_mc.onRollOver =effet_bouton;
          > btnSuivant_mc.onRollOver =effet_bouton;
          > btnPremier_mc.onRollOver =effet_bouton;
          > btnDernier_mc.onRollOver =effet_bouton;
          >
          > for (var i:Number = 0; i < arrID.length; i++) {
          > if (arrID ==_root.charte_mc.content_mc.acheter_mc.idselection){
          > chargeFiche(arrID
          );
          > idbiencurrent=i;
          > positionactuelle=idbiencurrent;
          > }
          > }
          >
          > function reinitialisation(fiche:Number):Void{
          > var t:String;
          > for (t in miniature_mc.ligne_mc){
          > removeMovieClip(miniature_mc.ligne_mc[t]);
          > }
          > for (t in placePhoto_mc){
          > removeMovieClip(placePhoto_mc[t]);
          > }
          > photoInitiale=false;
          > miniature_mc.ligne_mc._x=0;
          > scrollcompteur=0;
          > scrollx=0;
          > currentZoom=undefined;
          > chargeFiche(fiche);
          > }
          >
          > function chargeFiche(bienid:Number):Void{
          > photoInitiale=false;
          > strReference="";
          > strTypebien="";
          > strPrix="";
          > strSurface="";
          > strPieces="";
          > strVille="";
          > strDescriptif="";
          > lesImages =new Array();
          > bienxml = new XML();
          > bienxml.ignoreWhite = true;
          > bienxml.load(_root.urlFicheBien+"?bien_id="+bienid.toString());
          > bienxml.onLoad = function(success:Boolean) {
          > if (success) {
          > var biennodes:Array = this.firstChild.childNodes;
          > for (var ii:Number = 0; ii < biennodes.length; ii++) {
          > if (biennodes[ii].nodeName.toLowerCase()=="offre"){
          > strReference=biennodes[ii].attributes["id"];
          > for (var i:Number = 0; i < biennodes[ii].childNodes.length; i++) {
          > if (biennodes[ii].childNodes .nodeName.toLowerCase()=="typebien")
          > strTypebien=biennodes[ii].childNodes
          .firstChild.nodeValue;
          > if (biennodes[ii].childNodes .nodeName.toLowerCase()=="prix")
          > strPrix=biennodes[ii].childNodes
          .firstChild.nodeValue;
          > if (biennodes[ii].childNodes .nodeName.toLowerCase()=="surface")
          > strSurface=biennodes[ii].childNodes
          .firstChild.nodeValue;
          > if (biennodes[ii].childNodes .nodeName.toLowerCase()=="pieces")
          > strPieces=biennodes[ii].childNodes
          .firstChild.nodeValue;
          > if (biennodes[ii].childNodes .nodeName.toLowerCase()=="ville")
          > strVille=biennodes[ii].childNodes
          .firstChild.nodeValue;
          > if (biennodes[ii].childNodes .nodeName.toLowerCase()=="descriptif")
          > strDescriptif=biennodes[ii].childNodes
          .firstChild.nodeValue;
          > if (biennodes[ii].childNodes .nodeName.toLowerCase()=="photos") {
          > for (var a:Number = 0; a <
          > biennodes[ii].childNodes
          .childNodes.length; a++) {
          >
          > lesImages[a]=biennodes[ii].childNodes .childNodes[a].attributes["fichier"];
          > }
          > }
          > }
          > }
          > }
          > typebien_txt.text=strTypebien;
          > prix_txt.text=strPrix;
          > pieces_txt.text=strPieces;
          > surface_txt.text=strSurface;
          > ville_txt.text=strVille;
          > reference_txt.text=strReference;
          > descriptif_txt.text=strDescriptif;
          > compteur_txt.text=(idbiencurrent+1).toString()+" /
          > "+arrID.length.toString();
          > affichage();
          > } else {
          > trace('erreur d\'acc�s au fichier XML');
          > }
          > }
          > }
          > function affichage():Void{
          > var nomMc:String;
          > for (var i:Number=0;i<lesImages.length;++i){
          > nomMc="mini"+i+"_mc";
          > miniature_mc.ligne_mc.attachMovie("vignette_clip",nomMc,i);
          > miniature_mc.ligne_mc[nomMc]._x=34.5+(69*i);
          > miniature_mc.ligne_mc[nomMc]._y=35;
          > miniature_mc.ligne_mc[nomMc].onRelease=function(){
          > var b:MovieClip = this.getZoom();
          > ZoomPhoto(b);
          > }
          > placePhoto_mc.attachMovie("zoomMC","zoom"+i+"_mc",i);
          > placePhoto_mc[nomMc]._visible=false;
          > miniature_mc.ligne_mc[nomMc].setZoom(placePhoto_mc["zoom"+i+"_mc"]);
          > miniature_mc.ligne_mc[nomMc].setNumero(i);
          > var my_mcl:MovieClipLoader = new MovieClipLoader();
          > my_mcl.addListener(mcl_obj)
          >
          > my_mcl.loadClip(lesImages
          ,miniature_mc.ligne_mc[nomMc].vignette_mc.emplacement_mc);
          > my_mcl.loadClip(lesImages ,placePhoto_mc["zoom"+i+"_mc"].fgPhoto_mc);
          > }
          > if (lesImages.length>=5){
          > scrollcompteur=5;
          > }else{
          > scrollcompteur=lesImages.length;
          > }
          > }
          >
          >
          > mcl_obj.onLoadInit=function(target_mc:MovieClip):Void{
          > if (target_mc._name.substr(0,7)=="fgPhoto"){
          > if (target_mc._height>target_mc._width){
          > target_mc._width=target_mc._width*(46/target_mc._height);
          > target_mc._x+= (63-target_mc._width)/2;
          > target_mc._height=46;
          > if (!photoInitiale){
          > ZoomPhoto(placePhoto_mc["zoom0_mc"]);
          > photoInitiale=true;
          > }
          > }else{
          > target_mc._height=target_mc._height*(63/target_mc._width);
          > target_mc._width=63;
          > if (!photoInitiale){
          > ZoomPhoto(placePhoto_mc["zoom0_mc"]);
          > photoInitiale=true;
          > }
          > }
          > target_mc._x+=-32;
          > target_mc._y+=-26;
          > }else{
          > if (target_mc._height>target_mc._width){
          > target_mc._width=target_mc._width*(70/target_mc._height);
          > target_mc._x+= (93-target_mc._width)/2;
          > target_mc._height=70;
          > }else{
          > target_mc._height=target_mc._height*(93/target_mc._width);
          > target_mc._width=93;
          > }
          > }
          > }
          >
          >
          >
          > function ZoomPhoto(b:MovieClip){
          > var b:MovieClip=b;
          > b._visible=true;
          > if (currentZoom._name!=b._name){
          > swapDepths.call(b,10000);
          > b._alpha=100;
          > b.onEnterFrame = function () {
          > if (b._xscale < endScaleZoom) {
          > b._xscale += speedZoom;
          > b._yscale += speedZoom;
          > } else {
          > b._xscale = endScaleZoom;
          > b._yscale = endScaleZoom;
          > if (currentZoom._name!=undefined){
          > currentZoom._xscale = startScaleZoom;
          > currentZoom._yscale = startScaleZoom;
          > currentZoom._alpha=0;
          > }
          > currentZoom=b;
          > delete b.onEnterFrame;
          > }
          > }
          > }
          > }
          >
          >
          >
          >
          >
          > function navigation_fiche():Void{
          > if (arrID.length>0){
          > var positionactuelle:Number=idbiencurrent;
          > switch (this._name) {
          > case "btnPrecedent_mc" :
          > if (idbiencurrent>0) idbiencurrent-=1;
          > break;
          > case "btnPremier_mc" :
          > if (idbiencurrent>0) idbiencurrent=0;
          > break;
          > case "btnDernier_mc" :
          > if (idbiencurrent<arrID.length-1)idbiencurrent=arrID.length-1;
          > break;
          > case "btnSuivant_mc" :
          > if (idbiencurrent<arrID.length-1)idbiencurrent+=1;
          > break;
          > }
          > if (positionactuelle!=idbiencurrent)
          > reinitialisation(arrID[idbiencurrent]);
          > }
          > }
          > stop();
          >
          >