Skip navigation
Tomek74
Currently Being Moderated

Play a movieclip as element of an array

May 29, 2012 2:57 AM

Hi.

 

I'm learning (and trying to work with) as3, and have a problem:

how can i play a movieclip, which is an element of an array?

 

Code like this:

 

var mc:Array = new Array();

 

for(var k=0;k<=4;k++) {

     mc[k] = new MovieClip;

     addChild(mc[k]);

    

     var addAnim:MovieClip = new anim();  // class from a package, to add clip from library

     mc[k].addChild(addAnim);                  // add clips, which to be played

 

}

 

// first frames of child clips appears correctly

 

mc[0].play();  // nothing happens, no errors...

 

What do i wrong?

 
Replies
  • Currently Being Moderated
    May 29, 2012 4:21 AM   in reply to Tomek74

    The problem is that you are telling the container (parent) of the animation to play, not the animation.  THe mc array holds the 'MovieClip' instances, the MovieClip instances hold the animations.

     

    Try taking the MovieClips out of the picture...

     

    var mc:Array = new Array();

     

    for(var k=0;k<=4;k++) {

         mc[k] = new anim();  // class from a package, to add clip from library

        addChild(mc[k]);                  // add clip, which to be played

    }

     

    mc[0].play();

     
    |
    Mark as:
  • Currently Being Moderated
    May 29, 2012 5:05 AM   in reply to Tomek74

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points