events and conditions

47
Events and Conditions

Upload: elvis-barker

Post on 30-Dec-2015

37 views

Category:

Documents


0 download

DESCRIPTION

Events and Conditions. Events are things that happen. Onpress () Videos loaded Mouse click. Event Handlers. Something that runs when a certain event occurs. Open Events.fla. Select the first keyframe of actions layer and f9. Keyboard Control to Character. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Events and Conditions

Events and Conditions

Page 2: Events and Conditions

Onpress() Videos loaded Mouse click

Events are things that happen

Page 3: Events and Conditions

Something that runs when a certain event occurs.

Event Handlers

Page 4: Events and Conditions

Open Events.fla

Page 5: Events and Conditions

Select the first keyframe of actions layer and f9

Page 6: Events and Conditions

1st thing to do is to add an event listener. Tells an object to wait for a particular event to happen.

Set the keypress to the stage and not the boarder..

Keyboard Control to Character

Page 7: Events and Conditions

Add EventListener

Page 8: Events and Conditions

Event to listen for is called Keyboard Event

Page 9: Events and Conditions

Inport Line of Code-- Access

Page 10: Events and Conditions

Calling a function

Page 11: Events and Conditions

Creating a function

Page 12: Events and Conditions

Evt—represent the event the occurred.. Data sent to the function when a key is pressed.

Page 13: Events and Conditions

Datatype KeyboardEvent

Page 14: Events and Conditions

Line of code

Page 15: Events and Conditions

Void and Curley Braces

Page 16: Events and Conditions

Inside curley braces is what happen with a key press

Page 17: Events and Conditions

Move the skateboarder

Page 18: Events and Conditions

Test movie and press any key

Page 19: Events and Conditions

Explain

Event listener– connect event

EventAnd c

command

Page 20: Events and Conditions

Open Conditions.fla

Conditions– Programs that think and make decisions.

Page 21: Events and Conditions

Test the code all keys will make boarder move to right

Page 22: Events and Conditions

If a condition is met run a block of code

First frame f9

Page 23: Events and Conditions

Explain code

Page 24: Events and Conditions

Conditional statement to check which key was pressed

Page 25: Events and Conditions

() and {} wrapping or nesting

Page 26: Events and Conditions

Code cleanup

Page 27: Events and Conditions

If the key was press was RIGHT

Talk about evt

Page 28: Events and Conditions

keyCode

Page 29: Events and Conditions

== is compare is equal to = set a value is assign

Page 30: Events and Conditions

Move to right

Page 31: Events and Conditions

Test

Page 32: Events and Conditions

Make Left

Page 33: Events and Conditions

Right and left at same is a conflict

Page 34: Events and Conditions

Testd

Page 35: Events and Conditions

Neither

Page 36: Events and Conditions

Test

Page 37: Events and Conditions

Another way…

Select the if block and

delete

Page 38: Events and Conditions

Delete

Page 39: Events and Conditions

Switch case

Check the value of the keycode and do

different things based on the value.

Page 40: Events and Conditions

Case and value

Page 41: Events and Conditions

IF true tell flash what to do

Page 42: Events and Conditions

Stop looking for different options: break;

Page 43: Events and Conditions

Test

Page 44: Events and Conditions

Copy the case lines

Page 45: Events and Conditions

Test

Page 46: Events and Conditions

All other keys

Page 47: Events and Conditions

Test