art382 (interactive media)

instructor: ryanSmith
home | syllabus | contact | links | student work

Week 8

QUIZ

more with variables / progress bar / math.random / make a MC a BTN


if (exp) { statements }

• "conditional" statement
• exp is an expression that returns true or false
• if the expression returns true, the statements in the brackets are performed.

if (Math.random()>.9) { gotoAndPlay(3); }

• "Math" is an "object"
–a collection of functions and variables

• "random" is a function attached to "Math"
–returns a number between 0 and 1

• .034754372, .73583728, .937862612 ...
–different number every time

Basic usage of the if conditional:

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player


Download Target.fla



Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player


Download Random.fla

More examples:
art.umbc.edu
peggysirota.com
ryanSmithTHOTH

AS3 Progress Bar Component Tutorial

the progress bar code



MAKE A MOVIE CLIP A BUTTON

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player


box.buttonMode=true;
box.addEventListener(MouseEvent.CLICK, clickHandler);
box.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
box.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);

function clickHandler(evt:Object):void {
trace("You just clicked me!");
}
function mouseOverHandler(evt:Object):void {
box.gotoAndPlay(2);
}
function mouseOutHandler(evt:Object):void {
box.gotoAndPlay(10);
}




Homework:
FINISH PROJECT B