events and conditions
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 PresentationTRANSCRIPT
![Page 1: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/1.jpg)
Events and Conditions
![Page 2: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/2.jpg)
Onpress() Videos loaded Mouse click
Events are things that happen
![Page 3: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/3.jpg)
Something that runs when a certain event occurs.
Event Handlers
![Page 4: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/4.jpg)
Open Events.fla
![Page 5: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/5.jpg)
Select the first keyframe of actions layer and f9
![Page 6: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/6.jpg)
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](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/7.jpg)
Add EventListener
![Page 8: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/8.jpg)
Event to listen for is called Keyboard Event
![Page 9: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/9.jpg)
Inport Line of Code-- Access
![Page 10: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/10.jpg)
Calling a function
![Page 11: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/11.jpg)
Creating a function
![Page 12: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/12.jpg)
Evt—represent the event the occurred.. Data sent to the function when a key is pressed.
![Page 13: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/13.jpg)
Datatype KeyboardEvent
![Page 14: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/14.jpg)
Line of code
![Page 15: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/15.jpg)
Void and Curley Braces
![Page 16: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/16.jpg)
Inside curley braces is what happen with a key press
![Page 17: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/17.jpg)
Move the skateboarder
![Page 18: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/18.jpg)
Test movie and press any key
![Page 19: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/19.jpg)
Explain
Event listener– connect event
EventAnd c
command
![Page 20: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/20.jpg)
Open Conditions.fla
Conditions– Programs that think and make decisions.
![Page 21: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/21.jpg)
Test the code all keys will make boarder move to right
![Page 22: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/22.jpg)
If a condition is met run a block of code
First frame f9
![Page 23: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/23.jpg)
Explain code
![Page 24: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/24.jpg)
Conditional statement to check which key was pressed
![Page 25: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/25.jpg)
() and {} wrapping or nesting
![Page 26: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/26.jpg)
Code cleanup
![Page 27: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/27.jpg)
If the key was press was RIGHT
Talk about evt
![Page 28: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/28.jpg)
keyCode
![Page 29: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/29.jpg)
== is compare is equal to = set a value is assign
![Page 30: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/30.jpg)
Move to right
![Page 31: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/31.jpg)
Test
![Page 32: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/32.jpg)
Make Left
![Page 33: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/33.jpg)
Right and left at same is a conflict
![Page 34: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/34.jpg)
Testd
![Page 35: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/35.jpg)
Neither
![Page 36: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/36.jpg)
Test
![Page 37: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/37.jpg)
Another way…
Select the if block and
delete
![Page 38: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/38.jpg)
Delete
![Page 39: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/39.jpg)
Switch case
Check the value of the keycode and do
different things based on the value.
![Page 40: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/40.jpg)
Case and value
![Page 41: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/41.jpg)
IF true tell flash what to do
![Page 42: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/42.jpg)
Stop looking for different options: break;
![Page 43: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/43.jpg)
Test
![Page 44: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/44.jpg)
Copy the case lines
![Page 45: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/45.jpg)
Test
![Page 46: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/46.jpg)
All other keys
![Page 47: Events and Conditions](https://reader035.vdocument.in/reader035/viewer/2022062516/56812c2c550346895d90aae1/html5/thumbnails/47.jpg)
Test