This content has been marked as final. Show 6 replies
what do you mean by "triggering"? does that mean you want to create a movieclip instance on-stage using a movieclip that's in your library? (if yes, you'll need to use attachMovie() and give the library movieclip's linkage ids.)
and how do you decide whether to "trigger" movieAn or movieBn? are you choosing at random?
Sorry about the strange terminology. I am doing stuff with cameras and motion detection, so I guess i am caught-up in my own terminology.
The code example above calls 12 MCs to appear on stage (Movie1, Movie2.....)
These objects, mentioned in the code are in the library with 12 other objects which are not in the code (MovieB1, MovieB2, MovieB3...)
right now the code is pretty simple, and calls 12 objects in order 1-12
I want to achieve a situation where instead of 1,2,3,4,5,6.....
I will have 1 or B1, 2 or B2, 3 or B3, 4 or B4 etc...
Am I making more sense now? I hope I am not vague, I hope I need a simple random solution that can be applied on more or less what I have now.
Thanks for reading!
If your code works for what you want then you should only need to randomise the inclusion of the "B" in the library ID string in the attachmovie. Try this:
holder.attachMovie("Movie"+((Math.random() <.5)? "B":"")+i, "Movie"+i+"_"+j, holder.getNextHighestDepth());
If you want to know whether it was a B or a non-B clip that was used then you'll need to assign that value to a variable first so you can keep track of it and use the variable in its place in the attachMovie.
Although it sounds simple, I am not sure I am following on where to try it.
I will keep on testing with your example.
A technical question regarding that, and the way AS works:
Will that randomize once, when the application is being played? or every time the loop plays? (setInterval).
I am trying to play random clips every loop (twice a second).
Thanks for the quick reply and again hope I am clear.
All I posted was a replacement to the corresponding attachMovie portion of your code... as you had in your first post. If I've made a correct allowance for the wrapping it should be in the 6th line of code beginning with
var Movie:MovieClip = _root["Movie"+i] =holder.attachMovie etc
What I suggested is only making a change to the first parameter to include a B or no B in the library ID that's requested by the holder.attachMovie part.
The way its set up (if you use this changed attachMovie) it will randomise each time that makeAllMovies is called.
If I was doing something like this I'd be inclined to set up the holder clips once. And then load the randomised content clips inside on the setInterval call to something like your makeAllMovies function. I also think you'd need to use removeMovieClip for previously attached content clips before attaching each time as I don't think it just replaces ("overwrites") the old one. I've seen other posts where if you attachMovie the same library item with the same name in the same holder clip, you end up with 2 instances (flash apparently appends a number to one of them each time). If this is indeed the situation and happened each time, it would probably cause some problems.
Don't know if that helps. Kglad or others may have more insight in this area where I've indicated uncertainty.
I will do my tests, I just hope I was clear enough with describing my question.
Kglad was indeed helpful, I guess it also has to do with the fact that I just started messing with script not long ago.