Welcome to the navigation

Aliqua, laborum, in ut eiusmod officia eu qui proident, pariatur, ullamco veniam, ipsum aute dolore nostrud do in adipisicing quis dolor ea cillum non aliquip. Amet, ipsum consectetur veniam, laboris dolore in incididunt qui nisi excepteur deserunt enim proident, dolor non sit anim ut aute occaecat officia sed mollit commodo

Yeah, this will be replaced... But please enjoy the search!

Sleep in Flash AS3

I've noticed a lot of questions around the Internet regarding sleep() functions in Flash. Well, there isn't exactly a direct command to pause a Flash movie, instead we have to rely on the same type of functions available in JavaScript, setTimeout or setInterval. Alright, here it is

// Call the function, time in seconds
sleep(5);

function sleep(sec) {
	// Stops the script on the current frame
	stop();

	// The actual pause, and starter
	setTimeout(this.gotoAndPlay, sec*1000, this.currentFrame + 1);
}
I usually place the function inside a class, or in a bottom layer that's always included. That way I can just call the sleep() whenever I want.
Please note that this portal is a BETA site , I will continuously improve all functionality and performance during the coming weeks / the author