events and conditions
Post on 30-Dec-2015
39 Views
Preview:
DESCRIPTION
TRANSCRIPT
Events and Conditions
Onpress() Videos loaded Mouse click
Events are things that happen
Something that runs when a certain event occurs.
Event Handlers
Open Events.fla
Select the first keyframe of actions layer and f9
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
Add EventListener
Event to listen for is called Keyboard Event
Inport Line of Code-- Access
Calling a function
Creating a function
Evt—represent the event the occurred.. Data sent to the function when a key is pressed.
Datatype KeyboardEvent
Line of code
Void and Curley Braces
Inside curley braces is what happen with a key press
Move the skateboarder
Test movie and press any key
Explain
Event listener– connect event
EventAnd c
command
Open Conditions.fla
Conditions– Programs that think and make decisions.
Test the code all keys will make boarder move to right
If a condition is met run a block of code
First frame f9
Explain code
Conditional statement to check which key was pressed
() and {} wrapping or nesting
Code cleanup
If the key was press was RIGHT
Talk about evt
keyCode
== is compare is equal to = set a value is assign
Move to right
Test
Make Left
Right and left at same is a conflict
Testd
Neither
Test
Another way…
Select the if block and
delete
Delete
Switch case
Check the value of the keycode and do
different things based on the value.
Case and value
IF true tell flash what to do
Stop looking for different options: break;
Test
Copy the case lines
Test
All other keys
Test
top related