4 Replies Latest reply on Jan 31, 2011 11:24 PM by tommuseth

    Preloader swf not working in HTML

    tommuseth

      I've made a basic RSS news feed widget with a preloader. When I test the preloader in Flash it works fine, counting to 100% and bringing in the widget proper at the end. This happens both if I test the movie outright or simulate the download.

      But now I've embedded the preloader in an HTML file using swfobject 2.2, and the browser will only display the first frame of the preloader and go no further, ie it 'freezes' at 0%. When I open the actual preloader .swf file, it's the same - it just stops at 0% even though it worked fine previously when I exported it from its .fla file.

      Weird thing is, if I bypass the preloader and embed the widget file in my HTML, it works fine. This is for an assignment however, and I need to build a preloader as part of the criteria.

      All files (ie the widget .fla and .swf, the html and the preloader .fla and .swf) are in the same folder. Someone advised me when I made a bitmap in the preloader into a movie clip to uncheck the "export in frame 1" box, so I did this. It didn't work. Then someone else advised me to make sure the textbox containing the percentage count was a classic textbox with dynamic text. I did, and it's still not working.

      I'm at a loose end here. Any ideas? I've posted the ActionScript code i'm using below, but I'm not convinced it's the script in the preloader - a colleague is using the exact same code (with a different url request filename) and his works fine.

       

      var UrlRequest:URLRequest = new URLRequest("rss_feed.swf");
      var loader:Loader = new Loader();
      var per:Number;

       

      loader.load(UrlRequest);

       

      loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadingProgress);
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);

       

      function loadingProgress(event:ProgressEvent):void{
          var percent:Number = event.bytesLoaded/event.bytesTotal;   

          percent = Math.round(percent* 100);
          per = percent;
          flash_mc.gotoAndStop(per);
         
          trace(per +"%");
          flash_mc.numbers_txt.text = per + "%";
      }

       

      function onComplete(event:Event):void{
          addChild(loader);
      }

        • 1. Re: Preloader swf not working in HTML
          tommuseth Level 1

          ... I should add that I've created two instances on the stage for the preloader:

           

          1. A bitmap that fades in as the percentage counts upward, which I converted to a movie clip and called flash_mc.

          2. An empty textbox within this movie clip called numbers_txt.

          • 2. Re: Preloader swf not working in HTML
            Ned Murphy Adobe Community Professional & MVP

            How are the different files located relative to one another (html, preloader, and whatever the preloader loads)?

            • 3. Re: Preloader swf not working in HTML
              tommuseth Level 1

              All the files - rss_feed.html, rss_feed.fla and preloader.fla, plus rss_feed.swf and preloader.swf - are in one folder. I'm only using the one folder for everything, including an mp3 sound file and some .pngs I've imported into the library.

              • 4. Re: Preloader swf not working in HTML
                tommuseth Level 1

                Well, after testing on a remote server there's some good news. The preloader and widget both work fine after uploading to my college's server. I've been testing in Firefox on my local disk and that's been freezing, but things seem to be OK on another network.

                Still flummoxes me, but the point of the assignment is to upload the project to a server, not keep it on my local disk ... so I guess I'm happy. But I would like to know if anyone's experienced something similar in Flash, and whether there are some settings I need to tweak to get things working locally.