PDA

View Full Version : Selecting a range of clips ?


The Stranger
12-12-2002, 12:37 PM
I need a way in actionscript to select a range of movie clips that are sitting on the stage .

I have 100 movie clips, with instance names going from 'address01' through to 'address100'. What I need to be able to do is say in actionscript 'select everything from 'address01' through to 'address100' without actually having to type out all 100 instance names. Is there an easy way to do this in actionscript, I've thought about using loop counters but it doesn't really suit.

Any ideas ?

simontheak
12-12-2002, 01:23 PM
I don't know exactly what you want to do but I would have said a loop was just what you needed. Especially if you've named your movie clips like you have. Couldn't you have a function which contained a loop a bit like the on below:

for(i=0;i<=100;i++){
address[i].gotoAndPlay;
// or whatever your actions are;
}

Why do you think that loops wouldn't really suit?

The Stranger
12-12-2002, 02:26 PM
The main reason I didn't want to use loops was because i needed all 100 clips to move to a fixed location instantly. I thought that if I used a loop it would take longer to execute and that there would be a visible 'process' of clips moving as opposed to them all shifting at once.

But thanks for the code, I'll give it a try, see how it looks.

simontheak
12-12-2002, 02:30 PM
Originally posted by The Stranger
i needed all 100 clips to move to a fixed location instantly. I thought that if I used a loop it would take longer to execute and that there would be a visible 'process' of clips moving as opposed to them all shifting at once.

Oh ok - it might move quick enough, but I don't know. Can you let me know what happens?

The Stranger
12-12-2002, 03:14 PM
Doesn't seem to work for what I need it to do unfortunately, though that may be more to do with my lack of actionscript knowledge than the code itself.

Will keep trying.

Ricod
12-15-2002, 02:32 PM
I'm a little out of the whole scripting thing, but what they do for online gaming is, they incorporate a small delay. So what you do, is use the given code to 'tag' your mcs as 'selected', put them in a nice array for instance and THEN give the green light to move your mcs. This way you are assured that all your mcs will move at the same time. Building a real time strategy game :) ?

Instead of the gotoAndPlay, use _x = (x-coordinate) and _y = (y-coordinate) ofcourse.