11 Replies Latest reply on Aug 13, 2006 10:41 AM by julieta

    help! preloader and bmps that export for ActionScript

    julieta
      Hi, I know there have been severa postings about preloaders, but I still don't seem to understand this, so I hope some good soul out there can help me with this...please?!!!!
      I have a project in which I have my library full with jpg images (icons), and at the beginning of the movie I load each of them into movieclips using loadbitmap data and attach bitmap, to form like an endless strip of icons that acts as the menu. I am trying to build a preloader for this... the problem: i uncheck the "export in firstframe" at the linkage option for each of the bmps, but when I do this they don't load at all! Then I specify frame 2 in the publish settings-flash-ActionScript 2 classes, but everything stays the same. In the bandwidth profiler it doesn't show they will ever load. If I don't uncheck export in first frame for the images in the library, the preloader does not work either because it has to wait for them to load in the first frame....
      what should I do in this case? Is there something I am missing, or in theory should this work?
      please help!!
        • 1. Re: help! preloader and bmps that export for ActionScript
          kglad Adobe Community Professional & MVP
          the easiest thing to do is create a separate fla that contains your preload items only. you can then use:

          • 2. Re: help! preloader and bmps that export for ActionScript
            julieta Level 1
            sorry, i didn't understand that. By preload items you mean the preloader, or the images?or is that just calling my whole project in the first frame of another one?
            thanks...
            • 3. Re: help! preloader and bmps that export for ActionScript
              kglad Adobe Community Professional & MVP
              leave your current project as it currently is except remove your preloader code and preloader animation(s)/display(s) and place all that preloader code and animation(s)/display(s) in a separate fla.

              you are probably using something like _root.getBytesTotal() or this.getBytesTotal() or _level0.getBytesTotal() in your current preloader code. you should change that to _level1.getBytesTotal() and whereever you were using something.getBytesLoaded(), change that to _level1.getBytesLoaded().
              • 4. Re: help! preloader and bmps that export for ActionScript
                julieta Level 1
                still not working... sorry to keep bugging you... I'm using loadMovieNum to load a swf movie and it works, but when I try to make the preloader I get stuck. I use _level1.getBytesTotal and _level1.getBytesLoaded but I get "undfefined"... I check them with _level0 and they give me numbers...

                my loadermovie has 3 frames.
                on frame 1 I have:

                loadMovieNum("cielospreloadtest.swf",1);
                gotoAndPlay(2);

                on frame 2 I have:
                stop();
                var amount:Number;
                amount=_level1.getBytesLoaded() / _level1.getBytesTotal() * 100; //(these do not work);tried everythng in the first
                //frame and didn't work either.
                loader._xscale=amount;
                textamount.text=Math.round(amount) + "%"
                if (amount==100) {
                this.gotoAndPlay(3);
                }else{
                gotoAndPlay(2);
                };
                on frame 3 i have
                stop();
                • 5. Re: help! preloader and bmps that export for ActionScript
                  jlmsmith
                  Your code is only executing once. It might work if in an onEnterFrame event. But, try this code instead of the bytes loaded code. It is the loader class and works very well. Put it on one keyframe. Remove the other two. If you don't want to use the text fields then just comment the code out.

                  stop();
                  var myLoader:MovieClipLoader = new MovieClipLoader;
                  var myListener:Object = new Object();

                  myListener.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number) {
                  this.proportionloaded = target_mc.getBytesLoaded()/target_mc.getBytesTotal();
                  this.percentage = this.proportionloaded*100;
                  this.displaypercentage = Math.floor(this.percentage);
                  // display loading information in text fields on the stage...
                  this.loadPercent = this.displaypercentage + "%";
                  this.txt1.text ="--- LOADING ---";
                  }

                  myListener.onLoadInit = function(target_mc:MovieClip) {
                  myLoader.removeListener(this);
                  delete myListener;
                  delete myLoader;
                  _level1.play();
                  }
                  myListener.onLoadError = function(target_mc:MovieClip, errorCode:String) {
                  //....add code here for whatever you want to do in case of an error.
                  // I use the progress loading text field and write to it.
                  }
                  myLoader.addListener(myListener);
                  // Now load the files into their targets.
                  // loads into _level1
                  myLoader.loadClip("cielospreloadtest.swf.swf", 1);
                  • 6. Re: help! preloader and bmps that export for ActionScript
                    jlmsmith Level 1
                    Oops...remove the extra .swf from the file name in the last line of code. :)
                    • 7. Re: help! preloader and bmps that export for ActionScript
                      julieta Level 1
                      thanks for your answer! However, i don't know why it still doesn't work. I don't think is your script, because I also tried a script from a flash book cd, just changed the name of my movie, and it still did not work... the problem is always the same: the movie loads, but it just works as if there was no preloader. when I trace the variables, in this case I traced this.percentage, it starts already at 100. I do the same in the web, and the movie just takes time to download without anything showing on the screen...
                      I think I am just going crazy.
                      • 8. Re: help! preloader and bmps that export for ActionScript
                        julieta Level 1
                        i removed it, don't worry... but please read my former post....any ideas?
                        • 9. Re: help! preloader and bmps that export for ActionScript
                          jlmsmith Level 1
                          Just for kicks, instead of loading your movie into the level of another movie, add a scene to your movie before the scene that loads the clips. I would have the symbols exporting on the first keyframe. Put this code on the first keyframe of the load scene:

                          onEnterFrame = function(){
                          this.proportionloaded = this.getBytesLoaded()/this.getBytesTotal();
                          this.percentage = this.proportionloaded*100;
                          this.displaypercentage = Math.floor(this.percentage);
                          txt1.text ="--- LOADING DATA ---";
                          this.loadPercent = this.displaypercentage + "%";
                          if (displaypercentage == 100){
                          delete this.onEnterFrame;
                          this.play();
                          }
                          }

                          stop();

                          I will be interested to see if there is any difference.
                          • 10. Re: help! preloader and bmps that export for ActionScript
                            julieta Level 1
                            hi... nope... i've tried exporting to the second frame, to the first frame, and it does not work, neither if i put the preloader in the same movie, in a different scene, or if I call it from another movie. And i have tested the preloaders loading other movies and they work....
                            if I ever come across the solution, i'll post it here...
                            • 11. Re: help! preloader and bmps that export for ActionScript
                              julieta Level 1
                              I found one solution here:
                              http://www.bit-101.com/blog/?m=200409&paged=2

                              Basically, I build the preloader in the same movie that I'm loading, and I uncheck export to the first frame in the objects in the library that export for AS. I set frame 2 as the export frame for the movie in the publish settings. THEN, i have to make sure that ALL THE IMAGES THAT ARE exported for AS BE IN THE STAGE AT SOME POINT. (some frame that will never be seen). That's how flash knows that these files have to be exported at all.