Solved

Duplicate Movie Clip Pullling from Array

Posted on 2003-10-31
6
294 Views
Last Modified: 2010-04-03
I am attempting to duplicate all of the movie clips on the stage and assign each one a different instance name with one function. I have all of the movie clip names contained in an array (only two now). I had the code set to step through the array and grabe each mc, put that mc through the function, and then viola....BUUUUT no. Hours and many drinks later....here i am.
The problem i am having is that when this is run, it ONLY duplicates one mc in the array. The trace shows all of the instance names....wierd.....thanks in advance!

Here is the code that i have ended up with (boiled down version):

_root.nameArray = ['mca','mcb1'];
count = 0;
alpha = 60;
mca._alpha = alpha - 5;
mcb1._alpha = alpha - 5;
yscale = mca._yscale *= .3;
yscale = mcb1._yscale *= .3;

function dupMc(mc){
      trace("MC:" + mc);
      
      /*
      if(count > 30)
      {
            clearInterval(ID);
            return;
      }
      */
      count = 0;
      while(count < 30){
      duplicateMovieClip(_root.nameArray[mc], _root.nameArray[mc] + count, count+10);
      setProperty(_root.nameArray[mc] + count, _y, mca._y-((count+1)*10));
      setProperty(_root.nameArray[mc] + count, _alpha, alpha + count*2);
      setProperty(_root.nameArray[mc] + count, _yscale, yscale);
      yscale = yscale-0.2;
      trace("y: " + _root.nameArray[mc] + count);
      count++;
      }
      
}
//ID = setInterval(dupMc(0), 50);
//ID2 = setInterval(dupMc(1), 50);
dupMc(0);
dupMc(1);
0
Comment
Question by:ninjagnat
  • 3
  • 3
6 Comments
 

Author Comment

by:ninjagnat
Comment Utility
update points
0
 
LVL 27

Expert Comment

by:negatyve
Comment Utility
_root.nameArray = ['mca', 'mcb1'];
count = 0;
alpha = 60;
mca._alpha = alpha - 5;
mcb1._alpha = alpha - 5;
yscale = mca._yscale *= .3;
yscale = mcb1._yscale *= .3;
function dupMc(mc)
{
      trace("MC:" + mc);
      // ATTENTION!! you are duplicating movieclip
      // over the movieclips you have created before,
      // using the same depth parameter
      var count = mc * 30;
      var duplicando = _root[_root.nameArray[mc]];
      // or, if the movieclip reside in this timeline:
      // var duplicando = this[_root.nameArray[mc]];
      for(var i = count; i < count + 30; i++){
            var newClip = duplicando.duplicateMovieClip(_root.nameArray[mc] + i, i);
            newClip._y = mca._y - ((i + 1) * 10);
            newClip._alpha = alpha + (i * 2);
            newClip._yscale = yscale;
            yscale -= 0.2;
            trace("y: " + _root.nameArray[mc] + i);
      }
}
//ID = setInterval(dupMc(0), 50);
//ID2 = setInterval(dupMc(1), 50);
dupMc(0);
dupMc(1);
0
 

Author Comment

by:ninjagnat
Comment Utility
Still not working; it shows the movie clips in the trace trace("y: " + _root.nameArray[mc] + i) , but they do not duplicate. It is as if the for loop is just duplicating and then leaving them alone.

I appreciate your help greatly!! Any more ideas?

negatyve,
When i trace newClip from your code, it shows undefined.


Thanks!

-ninjagnat
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 27

Accepted Solution

by:
negatyve earned 250 total points
Comment Utility
0
 

Author Comment

by:ninjagnat
Comment Utility
DUDE! I bet you get ALL the chicks!! Thank you VERY much. I have no idea why it didn't work in my movie (obviously something i was doing wrong), but, I don't care, I just wanted to know if I was on the right track. Thanks again!

-ninjagnat
0
 
LVL 27

Expert Comment

by:negatyve
Comment Utility
that's ok! :)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now