13 Replies Latest reply on Dec 19, 2012 1:21 PM by kglad

    Create Empty Movie Clip in a Loop

    TheScarecrow Level 1

      I have an Array with image names in it.  I want to loop through the array and create empty movie clips and load an image into it.  I also want to do this in rows of 3.  RIght now I am just having trouble getting the images to load.  Any help would be appreciated.  Thanks.

       

      CODE:

      function placeImages() {

                trace("Place Images");

                trace(currentArray);

                startX = 110;

                startY = 86;

                xSpace = 63;

                xSpace = 50;

                row = 1;

                switch (currentArray)

                          {

                                    case "regArray2":

                                              for (var x = 1; x < regArray2.length+1; x++) {

                                                        //trace("AddChild");

                                                        this.createEmptyMovieClip("picture"+x, 1000);

                                                        this["picture"+x]._x = 110;

                                                        this["picture"+x]._y = 86;

                                                        this["picture"+x]._xscale = 10;

                                                        this["picture"+x]._yscale = 10;

                                                        this["picture"+x].loadMovie(regArray2[x]);

                                              }

                                              break;

                          }

      }

        • 1. Re: Create Empty Movie Clip in a Loop
          kglad Adobe Community Professional & MVP

          show regArray2 if the following fails:

           

          function placeImages() {

                    trace("Place Images");

                    trace(currentArray);

                    startX = 110;

                    startY = 86;

                    xSpace = 63;

                    xSpace = 50;

                    row = 1;

                    switch (currentArray)

                              {

                                        case "regArray2":

                                                  for (var x = 0; x < regArray2.length; x++) {

                                                            //trace("AddChild");

                                                            this.createEmptyMovieClip("picture"+x, this.getNextHighestDepth());

                                                            this["picture"+x]._x = x%3*200+100;

                                                            this["picture"+x]._y = 200*Math.floor(x/3)+100;

                                                          // scale after loading is complete

                                                            this["picture"+x].loadMovie(regArray2[x]);

                                                  }

                                                  break;

                              }

          }

          • 2. Re: Create Empty Movie Clip in a Loop
            TheScarecrow Level 1

            That is perfect.  I have one more question... how can I link them to a bigger image if they want to click on it and open it bigger within flash not a sepreate window?

            • 3. Re: Create Empty Movie Clip in a Loop
              kglad Adobe Community Professional & MVP

              flash (and i) need some way to determine the larger images' path/name.  that could be another array or some rule about converting the regArray2 element names to the large image names.

               

              p.s.  please mark helpful/correct responses.

              • 4. Re: Create Empty Movie Clip in a Loop
                TheScarecrow Level 1

                its the smae image.  That is why I was scaling it.

                • 5. Re: Create Empty Movie Clip in a Loop
                  kglad Adobe Community Professional & MVP

                  so, the initially loaded images are too large and you want to scale them down when loaded and scale them back up when clicked?

                   

                  if yes, you can use:

                   

                   

                  function placeImages() {

                            trace("Place Images");

                            trace(currentArray);

                            startX = 110;

                            startY = 86;

                            xSpace = 63;

                            xSpace = 50;

                            row = 1;

                            switch (currentArray)

                                      {

                                                case "regArray2":

                                                          for (var x = 0; x < regArray2.length; x++) {

                                                                    //trace("AddChild");

                                                                    this.createEmptyMovieClip("picture"+x, this.getNextHighestDepth());

                                                                    this["picture"+x].createEmptyMovieClip("loadTarget",0);

                                                                    this["picture"+x].loadTarget._xscale=this["picture"+x].loadTarget._yscale = 50;

                                                                    this["picture"+x]._x = x%3*200+100;

                                                                    this["picture"+x]._y = 200*Math.floor(x/3)+100;

                                                                    this["picture"+x].onRelease=function(){

                                                                         this.loadTarget._xscale=this.loadTarget._yscale=100;

                                                                    }

                                                                    this["picture"+x].loadTarget.loadMovie(regArray2[x]);

                                                          }

                                                          break;

                                      }

                  }

                  1 person found this helpful
                  • 6. Re: Create Empty Movie Clip in a Loop
                    TheScarecrow Level 1

                    Yes.  When they click on them I want them to scale up to normal.  then if they click off of the image it goes back to down to small size.

                    • 7. Re: Create Empty Movie Clip in a Loop
                      kglad Adobe Community Professional & MVP

                      using rollover and rollout will work better:

                       

                      function placeImages() {

                                trace("Place Images");

                                trace(currentArray);

                                startX = 110;

                                startY = 86;

                                xSpace = 63;

                                xSpace = 50;

                                row = 1;

                                switch (currentArray)

                                          {

                                                    case "regArray2":

                                                              for (var x = 0; x < regArray2.length; x++) {

                                                                        //trace("AddChild");

                                                                        this.createEmptyMovieClip("picture"+x, this.getNextHighestDepth());

                                                                        this["picture"+x].createEmptyMovieClip("loadTarget",0);

                                                                        this["picture"+x].loadTarget._xscale=this["picture"+x]._yscale = 10;

                                                                        this["picture"+x]._x = x%3*200+100;

                                                                        this["picture"+x]._y = 200*Math.floor(x/3)+100;

                                                                        this["picture"+x].onRollOver=function(){

                                                                             this.loadTarget._xscale=this.loadTarget._yscale=100;

                                                                        }

                                                                        this["picture"+x].onRollOut=function(){

                                                                             this.loadTarget._xscale=this.loadTarget._yscale=10;

                                                                        }

                                                                        this["picture"+x].loadTarget.loadMovie(regArray2[x]);

                                                              }

                                                              break;

                                          }

                      }

                      • 8. Re: Create Empty Movie Clip in a Loop
                        TheScarecrow Level 1

                        It doesnt seem to work right.  It scales it corretly in X direction but not the Y.  I am nost sure why.  Everything looks right.  Got any ideas?

                        1 person found this helpful
                        • 9. Re: Create Empty Movie Clip in a Loop
                          kglad Adobe Community Professional & MVP

                          there's a typo.  use:

                           

                           

                           

                          using rollover and rollout will work better:

                           

                          function placeImages() {

                                    trace("Place Images");

                                    trace(currentArray);

                                    startX = 110;

                                    startY = 86;

                                    xSpace = 63;

                                    xSpace = 50;

                                    row = 1;

                                    switch (currentArray)

                                              {

                                                        case "regArray2":

                                                                  for (var x = 0; x < regArray2.length; x++) {

                                                                            //trace("AddChild");

                                                                            this.createEmptyMovieClip("picture"+x, this.getNextHighestDepth());

                                                                            this["picture"+x].createEmptyMovieClip("loadTarget",0);

                                                                            this["picture"+x].loadTarget._xscale=this["picture"+x].loadTarget_yscale = 10;

                                                                            this["picture"+x]._x = x%3*200+100;

                                                                            this["picture"+x]._y = 200*Math.floor(x/3)+100;

                                                                            this["picture"+x].onRollOver=function(){

                                                                                 this.loadTarget._xscale=this.loadTarget._yscale=100;

                                                                            }

                                                                            this["picture"+x].onRollOut=function(){

                                                                                 this.loadTarget._xscale=this.loadTarget._yscale=10;

                                                                            }

                                                                            this["picture"+x].loadTarget.loadMovie(regArray2[x]);

                                                                  }

                                                                  break;

                                              }

                          }

                          1 person found this helpful
                          • 10. Re: Create Empty Movie Clip in a Loop
                            TheScarecrow Level 1

                            Awesome. Thanks.  You are great.

                            • 11. Re: Create Empty Movie Clip in a Loop
                              kglad Adobe Community Professional & MVP

                              you're welcome.

                              • 12. Re: Create Empty Movie Clip in a Loop
                                TheScarecrow Level 1

                                Kglad

                                Can this be altered so that the rollver places the image at like 100 20 and over all the other images?

                                1 person found this helpful
                                • 13. Re: Create Empty Movie Clip in a Loop
                                  kglad Adobe Community Professional & MVP

                                  the rollovered image can be placed at 100,20:

                                   

                                  using rollover and rollout will work better:

                                   

                                  function placeImages() {

                                            trace("Place Images");

                                            trace(currentArray);

                                            startX = 110;

                                            startY = 86;

                                            xSpace = 63;

                                            xSpace = 50;

                                            row = 1;

                                            switch (currentArray)

                                                      {

                                                                case "regArray2":

                                                                          for (var x = 0; x < regArray2.length; x++) {

                                                                                    //trace("AddChild");

                                                                                    this.createEmptyMovieClip("picture"+x, this.getNextHighestDepth());

                                                                                    this["picture"+x].createEmptyMovieClip("loadTarget",0);

                                                                                    this["picture"+x].loadTarget._xscale=this["picture"+x].loadTarget_ysc ale = 10;

                                                                                    this["picture"+x]._x = x%3*200+100;

                                                                                    this["picture"+x]._y = 200*Math.floor(x/3)+100;

                                  this["picture"+x].origX = this["picture"+x]._x;

                                  this["picture"+x].origY = this["picture"+x]._y;

                                                                                    this["picture"+x].onRollOver=function(){

                                                                                         this.loadTarget._xscale=this.loadTarget._yscale=100;

                                  this._x=100;

                                  this._y=20;

                                                                                    }

                                                                                    this["picture"+x].onRollOut=function(){

                                                                                         this.loadTarget._xscale=this.loadTarget._yscale=10;

                                  this._x=this.origX;

                                  this._y=this.origY;

                                                                                    }

                                                                                    this["picture"+x].loadTarget.loadMovie(regArray2[x]);

                                                                          }

                                                                          break;

                                                      }

                                  }