12 Replies Latest reply on Jul 27, 2006 10:04 PM by Ben2

    Loader.scaleContent not working

      i have a loader which loads jpeg images, and the scaleContent is set to true, yet sometimes when the pictures load, especially if its the first time you try to load them (they are not cached) it loads them full size and you can only see the top right corner of the image.
      if anyone has encountered this problem before or knows how to fix it, any helpful information or advice would be greatly appreciated.

      thanks beforehand, ben
      bf studios
        • 1. Re: Loader.scaleContent not working
          Trensic Level 1
          I have done this and hate it but there is a way to do this and it will work everytime unless you are use mutiple loaders...haven't figured that one out yet. What you need to do is create the loader dynaimically OR preload correctly. A good preloader is at www.gotoandlearn.com. for the dynamic loader see below.

          import mx.controls.Loader;

          var theLoader:Loader;
          theLoader = Loader(createClassObject(Loader, "theImage", 1));
          theLoader.scaleContent = true;
          theLoader.contentPath = "";
          theLoader.setSize(1*650, 1*500); // whatever you need
          theLoader.move(-320, -247); // whatever you need
          theLoader.contentPath = "1056.png"; // set content

          Oh, there is one other way...set your frame rate to 1...I know, I know but that works everytime.

          Have Fun
          • 2. Re: Loader.scaleContent not working
            Ben2 Level 1
            hmm... sorry i cant seem to get that to load a picture at all. I'm sure its something i'm doing wrong somehow, but anyway does anyone else have any suggestions? Thanks anyway, Trensic.
            • 3. Re: Loader.scaleContent not working
              Trensic Level 1
              That does work you just need to have the loader component in the library. Does not have to be on the stage but does have to be in the lib...

              I just opened a blank movie drop the code on, put a loader in the library, and saved it to a dir with the 1056.png file and it ran fine.

              If you want to try it this will work for the problem you are having. I have posted the same question on multiple forums with no luck so if you happen to find something please let me know.

              • 4. Re: Loader.scaleContent not working
                Ben2 Level 1
                wow that really does work
                guess i missed the whole 'have a loader in the library' bit
                thanks a lot bro, i appreciate it

                • 5. Re: Loader.scaleContent not working
                  Trensic Level 1
                  Glad you got it working...
                  • 6. Re: Loader.scaleContent not working
                    Ben2 Level 1
                    ok i just discovered that that method doesnt in fact work every time. the pics still come up oversized sometimes.


                    BF Studios
                    • 7. Re: Loader.scaleContent not working
                      Trensic Level 1
                      Let me guess ... If you test the movie in flash dev it works every time. If you run the swf outside of Flash Dev it works more times than not but still shows up non-scaled every now and again.

                      I had a similar problem the other day and after working with the loader component for a week or two I gave up and killed the loader. Now I am loading in a movie clip and scaling that clip down. Works every time.

                      If you really want to use the loader then the only thing you can do is set the frame rate to 1 or 2. That was the only way I could get it working even with a preloader and not exporting components in frame one / importing to frame 2.

                      My advice for what's it wroth: Just kill it and load/scale a movieclip. Save yourself and learn from my pain. If you need help with the movieclip let me know ...

                      Good Luck and Again, if you find out something please let me know,
                      • 8. Re: Loader.scaleContent not working
                        Ben2 Level 1
                        ok so wots the code for doing it in a movieclip?

                        • 9. Re: Loader.scaleContent not working
                          Trensic Level 1
                          Let me know if this does not work for you...Have Fun


                          // Mainpage_load is the instance name or the movie clip I am loading into

                          // start the preloader

                          // load the image

                          // preloader function
                          // NOTE: if it registers 100 percent before anything has happened you might have to do something else
                          function Preload() {
                          // preloader for image
                          this.onEnterFrame = function() {
                          // get percent of movie being loaded
                          percent = (Mainpage_load.getBytesLoaded()/Mainpage_load.getBytesTotal())*100;

                          // **** kill me just here to make sure it does not register 100 before loading anything

                          // if complete 100%
                          if (percent == 100) {
                          // scale the movieclip to size (play with the numbers)
                          Mainpage_load._xscale = Mainpage_load._xscale -= 60;
                          Mainpage_load._yscale = Mainpage_load._yscale -= 60;
                          // clean up
                          delete percent;
                          delete this.onEnterFrame;
                          • 10. Re: Loader.scaleContent not working
                            Ben2 Level 1
                            wow... that does seem to be working quite well so far, i'll keep playin with it.
                            thanks bro.

                            ive got it to resize while keeping aspect ratio so if you want the code for that...

                            i have a 300x225 movie clip centered on the stage with instance name "boundaryBox"
                            and a blank mc at 0,0 called "imgLoader"

                            • 11. Re: Loader.scaleContent not working
                              Ben2 Level 1
                              oops i meant to click preview

                              anyway that should work just like that, all the actions are on a black keyframe, its only one frame total..
                              good luck with that. i hate components im glad you found a way to do it without a loader component. i hope the scaling works.

                              if you want source fla just tell me ur email address.
                              thanks a lot, man
                              • 12. Re: Loader.scaleContent not working
                                Ben2 Level 1
                                replace the maintain aspect ratio paragraph with this one, it will work better: