6 Replies Latest reply on Oct 25, 2007 1:35 PM by Newsgroup_User

    preload problem

    Level 7
      I am trying to get 4 dynamic images to preload into the browser cache
      via actionscript. It works fine in all browsers EXCEPT Internet
      Explorer. Here is the script I used. I got it from Jesse Stratford's
      Sequential Preloader tutorial:

      stop();

      // setting intitial variables for each movieclip
      var image1:String;
      _root.txtImageURL.text = image1;

      var image2:String;
      _root.txtImageURL2.text = image2;

      var image3:String;
      _root.txtImageURL3.text = image3;

      var image4:String;
      _root.txtImageURL4.text = image4;

      // initialize counter variables
      count = 0;
      // how many movies are we going to be loading?
      numMoviesToLoad = 4;
      // define our loadNext function
      function loadNext () {
      // we're no longer preloading the last movie
      _root["loadmcImage"+count] = false;
      // send the percent bar back to it's first frame (0%)
      _root.bar.gotoAndStop(1);
      // if there are still movies which need loading
      if (count<numMoviesToLoad) {
      // incriment counter
      count++;
      // instance name for the next container MC
      var newName = "mcImage"+count;
      // duplicate the container MC
      _root.mcImage.duplicateMovieClip(newName, count);
      // this is my debugging code
      with (this[newName]) {
      _x = 0;
      _y = 0;
      _alpha = 0;
      }
      // end debugging
      // load the next movie in the sequence into the new container
      loadMovie (_root["image"+count], _root[newName]);
      // we are now preloading a new movie, set the var to True
      _root["load"+newName] = true;
      }
      else{
      _root.gotoAndPlay("startMovie");
      }
      }
      loadNext();

      This script basically loads an image dynamically from the text fields,
      which uses flashvars in the html document (full URL filenames).

      Then it puts them into a duplicate movieclip that is assigned a name.

      The problem is that in IE, it gets hung up on the first loading request.
      Nothing happens. Any ideas why? I think it may have something to do
      with the stop(); function in the code. Here is the link to the file.
      Remember to view it in IE:

      http://www.redheadcompanies.com/CLIENTS/Kann/2007_Kann/KannWebsite/homePics_dynamic.html

      any help will be greatly appreciated.

      thanks
        • 1. Re: preload problem
          kglad Adobe Community Professional & MVP
          where's _root["image"+count] defined?
          • 2. Re: preload problem
            Level 7
            It get's its value from the flashvars in the html file
            ie.
            "flashvars",'header=We+will+be+sensitive+to+the+integrity+of+a+space+and+a+structure...+a+ site+and+a+city...+a+community+and+a+purpose...+as+we+collaboratively+create+what+is+next. &image1=http://www.redheadcompanies.com/CLIENTS/Kann/2007_Kann/KannWebsite/images/HomePics /wolfeStreetInterior.jpg',

            Then brought into the dynamic input textbox and loaded into the
            duplicate movieclip "mcImage"

            var image1:String;
            _root.txtImageURL.text = image1;

            hope this helps

            thanks for your responce.

            kglad wrote:
            > where's _root["image"+count] defined?
            • 3. Re: preload problem
              kglad Adobe Community Professional & MVP
              and is that value being loaded correctly in ie?
              • 4. Re: preload problem
                Level 7
                yes, I believe so.

                Here is the code in the first frame of my flash movie:

                stop();

                // setting intitial variables for each movieclip
                var image1:String;
                _root.txtImageURL.text = image1;

                var image2:String;
                _root.txtImageURL2.text = image2;

                var image3:String;
                _root.txtImageURL3.text = image3;

                var image4:String;
                _root.txtImageURL4.text = image4;

                // initialize counter variables
                count = 0;
                // how many movies are we going to be loading?
                numMoviesToLoad = 4;
                // define our loadNext function
                function loadNext () {
                // we're no longer preloading the last movie
                _root["loadmcImage"+count] = false;
                // send the percent bar back to it's first frame (0%)
                _root.bar.gotoAndStop(1);
                // if there are still movies which need loading
                if (count<numMoviesToLoad) {
                // incriment counter
                count++;
                // instance name for the next container MC
                var newName = "mcImage"+count;
                // duplicate the container MC
                _root.mcImage.duplicateMovieClip(newName, count);
                // this is my debugging code
                with (this[newName]) {
                _x = 0;
                _y = 0;
                _alpha = 0;
                }
                // end debugging
                // load the next movie in the sequence into the new container
                loadMovie (_root["image"+count], _root[newName]);
                // we are now preloading a new movie, set the var to True
                _root["load"+newName] = true;
                }
                else{
                _root.gotoAndPlay("startMovie");
                }
                }
                loadNext();



                Here is the code in the movieclip that is being duplicated:

                onClipEvent (enterFrame) {
                // if this movie needs preloading
                if (_root["load"+this._name]) {
                // has the loadMovie command been processed yet?
                if (total_bytes == null) {
                total_bytes = this.getBytesTotal();
                } else {
                // controll bar - standard % preloader code
                loaded_bytes = this.getBytesLoaded();
                remaining_bytes = total_bytes-loaded_bytes;
                percent_done = int((loaded_bytes/total_bytes)*100);
                _root.bar.gotoAndStop(percent_done);
                // if loading is complete
                if (percent_done == 100) {
                //trace ("fully loaded");
                // not loading this one any more, load the next
                _root["load"+this._name] = false;
                _root.loadNext();
                }
                }
                }
                }




                And this is the code I use in my HTML document with the flashvars:


                <script language="JavaScript" type="text/javascript">
                <!--
                var hasRightVersion = DetectFlashVer(requiredMajorVersion,
                requiredMinorVersion, requiredRevision);
                if(hasRightVersion) { // if we've detected an acceptable version
                if (AC_FL_RunContent == 0) {
                alert("This page requires AC_RunActiveContent.js. In Flash, run
                \"Apply Active Content Update\" in the Commands menu to copy
                AC_RunActiveContent.js to the HTML output folder.");
                } else {
                // embed the flash movie
                AC_FL_RunContent(
                'codebase',
                ' http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0',

                "flashvars",'header=We+will+be+sensitive+to+the+integrity+of+a+space+and+a+structure...+a +site+and+a+city...+a+community+and+a+purpose...+as+we+collaboratively+create+what+is+next .&image1=http://www.redheadcompanies.com/CLIENTS/Kann/2007_Kann/KannWebsite/images/HomePic s/wolfeStreetInterior.jpg',
                'width', '666',
                'height', '360',
                'src', 'homePics_dynamic',
                'quality', 'high',
                'pluginspage', ' http://www.macromedia.com/go/getflashplayer',
                'align', 'middle',
                'play', 'true',
                'loop', 'true',
                'scale', 'showall',
                'wmode', 'window',
                'devicefont', 'false',
                'id', 'homePics_dynamic',
                'bgcolor', '#1d3636',
                'name', 'homePics_dynamic',
                'menu', 'true',
                'allowScriptAccess','sameDomain',
                'movie', 'homePics_dynamic',
                'salign', ''
                ); //end AC code
                }
                } else { // flash is too old or we can't detect the plugin
                var alternateContent = 'Alternate HTML content should be placed here.'
                + 'This content requires the Macromedia Flash Player.'
                + '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';
                document.write(alternateContent); // insert non-flash content
                }
                // -->
                </script>

                • 5. Re: preload problem
                  kglad Adobe Community Professional & MVP
                  that's too much to go through.

                  use a textfield to display your flashvars. then check in ie.
                  • 6. Re: preload problem
                    Level 7
                    I did what you suggested, and it works fine in IE, so my guess is it has
                    something to do with the stop(); function.

                    Is there any suggestions or tutorials you can give that I can learn from
                    on how to preload multiple files dynamically via flashvars?

                    I appreciate your time.

                    Thanks