2 Replies Latest reply on Aug 26, 2010 3:20 PM by borys_k

    button preloader


      I would like a button to create a preloader and load a swf file.


      this is what i wrote in AS

      it tells me that script is ok so I'm not sure what is the problem.


      photo.onRelease = function() {

           _root.createEmptyMovieClip("bar", 2);

           bar._x = 400;

           bar._y = 300;

           bar._alpha = 70;

           bar.color = black;

           bar._height = 25;

           bar._width = 0;

           loadMovie("slider.swf", Cont);

           Cont.onEnterFrame = function() {

                var ldd = this.Cont.getBytesLoaded();

                var ttl = this.Cont.getBytesTotal();

                var prcnt = int(ldd/this);

                if (ldd<ttl) {

                Cont._alpha = 0;

                bar._width = prcnt*200;

                } else {

                bar._alpha = 0;

                Cont._alpha = 100;





      The script is in the frame, not on a button

        • 1. Re: button preloader
          borys_k Level 1

          Ah and I changed the button to a movie clip and it loads the content to a movie clip Cont that is on the main stage but the preloader doesn't work. the to be loaded is about 45 Kb but it is for my testing for future use.

          • 2. Re: button preloader
            borys_k Level 1

            help please!


            I tried a new script. But it still doesn't want to work. it is like this


            photo.onPress = function(){


            bio.onPress = function(){


            design.onPress = function(){


            function startPreload(url){
            attachMovie("preloader anim", "prldr", 500, {_x:400, _y:300});

            onEnterFrame = preloadContainer;


            //and in same frame different layer


            function preloadContainer(){
                 ar ldd = Cont.getBytesLoaded();

                 var ttl = Cont.getBytesTotal();

                  Cont._visible = false;

                  if (bytes_total > 0){
                       var prcnt = ldd/ttl;
                       preloader_mc.value = prcnt;

                           if (prcnt == 1){


                                    Cont._visible = true;

                            delete onEnterFrame;



            that's it.


            I checked. The movie clip that swfs are loaded into has instance "Cont"

            other instances are also ok. photo, bio and design are instances of buttons.


            Bio loads the swf but the preloader is not showing up. Photo doesn't load the swf and preloader at all ;/


            help help help!