Skip Navigation.

Flash: Making a Crystal Ball

To make a Flash crystal ball, we'll be using an array and a button. Arrays are like small databases holding information, making it easily accessible for you and your scripts.

on (release) {
	// make array (list) of possible responses
	responses = new Array();
	//below are the responses, change these to fit the fortune you want to give
	responses.push("Yes");
	responses.push("Eat a cookie.");
	responses.push("Cookies are good for you.");
	responses.push("Chocolate will make you live longer.");

	// get number of responses
	n = responses.length;

	// pick random response
	r = Int(Math.random()*n);

	// place response in text area
	magicfortune = responses[r];

	// start animation
	gotoAndPlay(2);
}

Replay Button

Then, you may want to add another button with a replay function - a button that asks something like "Again?" On that button, you'd just put the code:

on (release) {
	gotoAndPlay(1);
}

Here's one example of a finalized working Flash Crystal Ball, and here's the .fla file.

Here's a prettier, and sillier, example using one of the O'Reilly mascots and the .fla file.

Back