Flash actionscripting question
Date: 09/26/06
(Web Development) Keywords: no keywords
I'm trying to make a flash movie that consists of a grid of thirty squares (called boxes in my movie). Each box is a movie clip. In each box movieclip is 9 different image movie clips. Each image movie clip is animated so that it will fade in for 20 frames and fade out for 20 frames. A stop(); is coded for frame 1 and frame 20 of each image movie clip.
The code below is in my main movie. I want the boxes to randomly fade in with a random image, stay for a random amount of time, and then fade out. So that the end result is a grid of images that randomly fade in and out continuously. As of right now, it does not work. The movie is just blank.
Is my context bad? Am I going about it in the wrong way? Thanks everyone.
**Btw, randRange creates a random number between (and including) the two numbers you drop into it. I've used it before and know it works.
_root.onEnterFrame = function()
{
trace("begin");
for (var i = 0; i < 30; i++)
{
trace("box");
var nm = "box" + i; //go through the thirty boxes
var nm = "image" + (randRange(0,8)); //Pick one of the 9 images in the box
trace("image");
_root[nm]._root[nm2].onEnterFrame = function()
{
if (this._currentframe == 1)
{
if ( (randRange(0,99) < 50) ) //Play 50% of the time
{
this.play();
} //CLOSE if
} //CLOSE if
else if (this._currentframe == 20)
{
if ( (randRange(0,99) < 50) ) //Finish movie clip 50% of the time
{
this.play();
} //CLOSE if
} //CLOSE else if
} //CLOSE _root[nm].onEnterFrame = function
} //CLOSE for
} //CLOSE _root.onEnterFrame = function
Source: http://community.livejournal.com/webdev/356037.html