I’ve got the code for circle on an image (mask).
I’ve got it in my first frame and I need do something else in 2nd frame but after the movie in 1st frame is finished.
Can you help me please?
//This container contains all the circles that act as a mask for the picture
var container:Sprite = new Sprite();
//Assign the container to be the image's mask
picture.mask = container;
//Add the container to the stage
addChild (container);
/*
This timer is responsible for creating a circle every 0.05 seconds.
A total of 20 circles will be created.
*/
var timer = new Timer(50,20);
timer.addEventListener (TimerEvent.TIMER, createMaskBall);
timer.start ();
//The timer calls this function every 0.05 seconds
function createMaskBall (e:Event):void {
//Create a new MaskBall
var maskBall:MaskBall = new MaskBall();
//Set scale to zero so it won't be visible at the beginning
maskBall.scaleX = 0;
maskBall.scaleY = 0;
//Assign a random position in the stage
maskBall.x = Math.random() * stage.stageWidth;
maskBall.y = Math.random() * stage.stageHeight;
//Add the maskBall to the container
container.addChild (maskBall);
//We need ENTER_FRAME function to handle the animation
maskBall.addEventListener (Event.ENTER_FRAME, animateMaskBall);
}
//This function is called in every frame
function animateMaskBall (e:Event):void {
//Increase the scale
e.target.scaleX += 0.05;
e.target.scaleY += 0.05;
}