Help Me As Gurus!

me again. please help

i = 0;
roots = new Array(blueSquare)
roots*._x = squareX;
roots*._y = squareY;
roots*._width = squareWidth;
roots*._height = squareheight;
[COLOR=red]roots*.play();[/COLOR]

everything will work except that last line, why doesn’t it play?

try
roots = new Array(this[blueSquare])

nooope, thx anyways

I take it you have a stop() inside blueSquare? If so, that will stop the clip and wont let it play. Code on that timeline will be run before code within movieclips in the timeline. Telling blueSquare to play will only make it play until it reads its own timeline and stop() command where its then told to stop - therefore making it stop instead.

Alternatives.

  1. obviously, dont put a stop in the movieclip

  2. putting a condition in the movieclip to check a variable to see whether it should stop or not. ex:

// in blueSquare
if (!shouldPlay) stop();

// in the timeline
i = 0;
// ...
roots*.shouldPlay = true;

note that in this situation the playing will repeat unless you set shouldPlay to false since the stop still wont be called when the clip loops back to frame 1 after playing through

  1. use an onEnterFrame workaround to tell the movieclip to play on the next frame (after the stop has been called)
roots*.onEnterFrame = function(){
	this.gotoAndPlay(2); 
	delete this.onEnterFrame;
};

This of course could cause a problem if you’re defining onEnterFrame for something else, but you could then just use a simple if check to only have the goto called on the first run similar to the shouldPlay kind of deal.

  1. redefine the stop command for the movieclip to be a play command. this is a little unorthodox but its something thats nice to know is at least possible.
root*.stop = play;

Then when the stop command is run, it plays instead of stops. Better yet, since a movieclip plays on its own to begin with, theres no point in telling it to play again, so along the same lines of the onEnterFrame deal, you can redefine the stop command to be a function that undefines the redefine effectively only having it redefined for a single instance of its call:

roots*.stop = function(){
	delete this.stop;
};

Of course with these changes, you’ll need to be sure you are using this.stop() in the blueSquare clip and not just stop(); (which would call the tl function of stop and not the stop method of the movieclip which is what we are temporarily redefining).