Skip to main content
Known Participant
April 21, 2014
Answered

Actionscript 2.0 Movie Clip Variable Array help

  • April 21, 2014
  • 1 reply
  • 731 views

I just want to use multiple attached movie clip as array, btw this is the simple code :

if(_global.plevel == 0)
{
           var box1:MovieClip = _root.attachMovie("flip_box_lg", "fb1",  this.getDepth()+5,{_x:100,_y:100});
           box1._width = 100;
           box1._height = 40;
           box1._x = 60;
           box1._y = 80;
           var box2:MovieClip = _root.attachMovie("flip_box_lg", "fb2",  this.getDepth()+6,{_x:100,_y:100});
           box2._width = 100;
           box2._height = 40;
           box2._x = 170;
           box2._y = 80;
           this.onEnterFrame=assignF;
}

can I just making it like this ?

for(var i=0;i<6;i++)
{
      var box:MovieClip = _root.attachMovie("flip_box_lg", "fb"+(i+1),  this.getDepth()+5,{_x:60+(i*110),_y:80});
}

Thank you before

This topic has been closed for replies.
Correct answer kglad

use:

var box:Array=[];

for(var i=0;i<6;i++)
{
      box.push( _root.attachMovie("flip_box_lg", "fb"+(i+1), _root.getNextHighestDepth(),{_x:60+(i*110),_y:80}));
}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 21, 2014

use:

var box:Array=[];

for(var i=0;i<6;i++)
{
      box.push( _root.attachMovie("flip_box_lg", "fb"+(i+1), _root.getNextHighestDepth(),{_x:60+(i*110),_y:80}));
}

JiQAuthor
Known Participant
April 22, 2014

Thank you so much before, it works perfectly, but how to do onRelease with that movie clip array ?

box.onRelease = function () {

    if(_global.menushow == 0)

          {

                    this.play();

          }

}

JiQAuthor
Known Participant
April 22, 2014

eh, already done by using

for(var i=0;i<4;i++)

{

          box.onRelease = function () {

                    if(_global.menushow == 0)

                    {

                              this.play();

                    }

is that already right or have another more effiicient one ?

Thanks before