This flash movie demonstrates the use of Flash functions to increase and decrease the size of circles, rotate circles and change the colour of the circles.
Watch the movie, then scroll down to view the code or alternatively download the Flash file.
This movie works on the basis of 2 main movie clips, mcRainbow and mcRed.
mcRainbow simply provides the frame for mcRed and is a rainbow-coloured circle that
rotates by increments of 1 whatever action is taking place on mcRed.
mcRed is where the real action takes place and calls the functions to expand and shrink (growCircle and shrinkCircle) dependent on what size it has reached. It also attaches different coloured circles as movie clips in a cycle defined by the shrinkCircle function.
Here's the code -
mcRed._width=1;
mcRed._height=1;
myObj = new Object();
var colourCount;
colourCount = 1;
myObj.growCircle = function () {
mcRed._width+=1;
mcRed._height+=1;
mcRainbow._rotation+=1;
if(mcRed._width>190) {
clearInterval(myGrowInterval);
myShrinkInterval = setInterval(myObj, "shrinkCircle", 25);
}
}
myObj.shrinkCircle = function () {
mcRed._width-=1;
mcRed._height-=1;
mcRainbow._rotation+=1;
if(mcRed._width<3) {
clearInterval(myShrinkInterval);
colourCount++
switch (colourCount) {
case 2:
mcRed.attachMovie("mcOrange","mcOrange",1);
break;
case 3:
mcRed.attachMovie("mcYellow","mcYellow",1);
mcRed.removeMovieClip("mcOrange");
break;
case 4:
mcRed.attachMovie("mcGreen","mcGreen",1);
mcRed.removeMovieClip("mcYellow");
break;
case 5:
mcRed.attachMovie("mcBlue","mcBlue",1);
mcRed.removeMovieClip("mcGreen");
break;
case 6:
mcRed.attachMovie("mcIndigo","mcIndigo",1);
mcRed.removeMovieClip("mcBlue");
break;
case 7:
mcRed.attachMovie("mcViolet","mcViolet",1);
mcRed.removeMovieClip("mcIndigo");
break;
case 8:
mcRed.attachMovie("mcRed","mcRed",1);
mcRed.removeMovieClip("mcViolet");
colourCount=1;
break;
}
myGrowInterval = setInterval(myObj, "growCircle", 25);
}
}
myGrowInterval = setInterval(myObj, "growCircle", 25);