7 Replies Latest reply on Mar 24, 2010 12:07 PM by kglad

    Preloader Adjustment

    kitster79 Level 1

      Hello,

       

      I just launched my new website (I am a graphic designer) and I used a pre-existing flash pre-loader on my home page that was created for me from another project. The loading bar used to be shorter but I stretched it out to be wider. The problem is that now the actual progress bar does not go all the way across to 100%. I’m pretty sure it’s just a number change that needs to be done somewhere in the code – I just don’t know where.

      If at all possible I would greatly appreciate it if you could point me in the right direction:)

       

      Here is the pre-loader I’m talking about – http://www.vojodesign.com

      Here is my script:

       

      import fl.transitions.TweenEvent;
      import flash.utils.getDefinitionByName;
      import flash.events.Event;
      import flash.net.navigateToURL;
      import flash.net.URLRequest;

       

      var links_list:Array=["index.php?option=com_content&view=article&id=37&Itemid=14",
                            "index.php?option=com_content&view=article&id=38&Itemid=9",
                            "index.php?option=com_content&view=article&id=17&Itemid=10",
                            "index.php?option=com_content&view=article&id=37&Itemid=11"];

       

      this.StartPreloading();
      function StartPreloading(){
          this.addEventListener(Event.ENTER_FRAME,this.onPreloaderEnterFrame);
          this.SetProgress(0);
      }
      function onPreloaderEnterFrame(ev:Event){
          var clip_total=this.loaderInfo.bytesTotal;
          var clip_loaded=this.loaderInfo.bytesLoaded;
          var clip_progr=clip_loaded/clip_total;
          var progr=clip_progr;
          this.SetProgress(progr);
          if(progr>=1){
              this.removeEventListener(Event.ENTER_FRAME,this.onPreloaderEnterFrame);
              this.gotoAndPlay("go");
          }
      }
      function SetProgress(val:Number){
          this.Preloader_mc.Text_txt.text=Math.round(val*100);
          this.Preloader_mc.Bar_mc.Progress_mc.Line_mc.scaleX=val;
      }

       

      var current_tab:int=0;
      var current_slide=null;

       

      function SetupButtons(){
          for(var i=0;i<5;i++){
              var button=this.Buttons_mc.getChildByName("bn"+i);
              button.AddListener(String(i),this.onMenuButton);
              if(i==this.current_tab) button.is_selected=true;
          }
      }
      function onMenuButton(cmd:String){
          var button=this.Buttons_mc.getChildByName("bn"+this.current_tab);
          button.is_selected=false;
          button=this.Buttons_mc.getChildByName("bn"+cmd);
          button.is_selected=true;
          this.current_tab=int(cmd);
          this.SwitchToSlide();
      }
      function SwitchToSlide(){
          var class_ref:Class=getDefinitionByName("slide"+String(this.current_tab)) as Class;
          var slide=new class_ref();
          slide.predecessor=this.current_slide;
          if(this.current_tab>0){
              slide.link=this.links_list[this.current_tab-1];
          }
          this.addChild(slide);
          this.current_slide=slide;
          this.current_slide.Reveal();
      }
      function onSlideShown(ev:TweenEvent){
      }

      Thanks in advance.

        • 1. Re: Preloader Adjustment
          kglad Adobe Community Professional & MVP

          this.Preloader_mc.Bar_mc.Progress_mc.Line_mc.scaleX=val;

           

          is the line of code that's causing the problem.  you were scaling that movieclip to 1 (or full width).  after you made your changes, full width is less than you want.

           

          to remedy, IF that movieclip starts full-width, you could store the full width of that movieclip using:

           

          var Line_mcW:Number = this.Preloader_mc.Bar_mc.Progress_mc.Line_mc.width;

           

          and use:

           

          this.Preloader_mc.Bar_mc.Progress_mc.Line_mc.width=val*Line_mcW;

          • 2. Re: Preloader Adjustment
            kitster79 Level 1

            Thanks for your swift response. So I swapped this...

             

            function SetProgress(val:Number){
                this.Preloader_mc.Text_txt.text=Math.round(val*100);
                this.Preloader_mc.Bar_mc.Progress_mc.Line_mc.scaleX=val;
            }

             

            for this...

             

            function SetProgress(val:Number){
                var Line_mcW:Number = this.Preloader_mc.Bar_mc.Progress_mc.Line_mc.width;
                this.Preloader_mc.Bar_mc.Progress_mc.Line_mc.width=val*Line_mcW;
            }

             

            Is that what you meant?  The preloader dosnt do anything now:(

            • 3. Re: Preloader Adjustment
              kglad Adobe Community Professional & MVP

              that won't work, as you know.

               

              try:

               


               

              import fl.transitions.TweenEvent;
              import flash.utils.getDefinitionByName;
              import flash.events.Event;
              import flash.net.navigateToURL;
              import flash.net.URLRequest;

               

              var links_list:Array=["index.php?option=com_content&view=article&id=37&Itemid=14",
                                    "index.php?option=com_content&view=article&id=38&Itemid=9",
                                    "index.php?option=com_content&view=article&id=17&Itemid=10",
                                    "index.php?option=com_content&view=article&id=37&Itemid=11"];

               

              var Line_mcW:Number=this.Preloader_mc.Bar_mc.Progress_mc.Line_mc.width;

              trace(Line_mcW):  // if this is zero, you'll need to change the above line of code

               

              this.StartPreloading();
              function StartPreloading(){
                  this.addEventListener(Event.ENTER_FRAME,this.onPreloaderEnterFrame);
                  this.SetProgress(0);
              }
              function onPreloaderEnterFrame(ev:Event){
                  var clip_total=this.loaderInfo.bytesTotal;
                  var clip_loaded=this.loaderInfo.bytesLoaded;
                  var clip_progr=clip_loaded/clip_total;
                  var progr=clip_progr;
                  this.SetProgress(progr);
                  if(progr>=1){
                      this.removeEventListener(Event.ENTER_FRAME,this.onPreloaderEnterFrame);
                      this.gotoAndPlay("go");
                  }
              }
              function SetProgress(val:Number){
                  this.Preloader_mc.Text_txt.text=Math.round(val*100);
                  this.Preloader_mc.Bar_mc.Progress_mc.Line_mc.width=val*Line_mcW;
              }

               

              var current_tab:int=0;
              var current_slide=null;

               

              function SetupButtons(){
                  for(var i=0;i<5;i++){
                      var button=this.Buttons_mc.getChildByName("bn"+i);
                      button.AddListener(String(i),this.onMenuButton);
                      if(i==this.current_tab) button.is_selected=true;
                  }
              }
              function onMenuButton(cmd:String){
                  var button=this.Buttons_mc.getChildByName("bn"+this.current_tab);
                  button.is_selected=false;
                  button=this.Buttons_mc.getChildByName("bn"+cmd);
                  button.is_selected=true;
                  this.current_tab=int(cmd);
                  this.SwitchToSlide();
              }
              function SwitchToSlide(){
                  var class_ref:Class=getDefinitionByName("slide"+String(this.current_tab)) as Class;
                  var slide=new class_ref();
                  slide.predecessor=this.current_slide;
                  if(this.current_tab>0){
                      slide.link=this.links_list[this.current_tab-1];
                  }
                  this.addChild(slide);
                  this.current_slide=slide;
                  this.current_slide.Reveal();
              }
              function onSlideShown(ev:TweenEvent){
              }


              • 4. Re: Preloader Adjustment
                kitster79 Level 1

                This is what came up in the error panel:

                 

                script.as, Line 16

                 

                1078: Label must be a simple identifier.

                 

                trace(Line_mcW):  // if this is zero, you'll need to change the above line of code

                • 5. Re: Preloader Adjustment
                  kglad Adobe Community Professional & MVP

                  that should be a semi-colon, not a colon.

                  • 6. Re: Preloader Adjustment
                    kitster79 Level 1

                    It works perfectly!  Thank you for your help kglad:)

                    • 7. Re: Preloader Adjustment
                      kglad Adobe Community Professional & MVP

                      you're welcome.

                       

                      p.s.  please mark this thread as answered, if you can.