1 / 30

A Preview of Event-Driven Programming CS225 Presented By: Brandon Gigot & Joe Cohen

A Preview of Event-Driven Programming CS225 Presented By: Brandon Gigot & Joe Cohen. A Brief Introduction. Joe and Brandon are both Computer Science Majors at St. Norbert College

quanda
Download Presentation

A Preview of Event-Driven Programming CS225 Presented By: Brandon Gigot & Joe Cohen

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Preview of Event-Driven ProgrammingCS225Presented By:Brandon Gigot & Joe Cohen

  2. A Brief Introduction Joe and Brandon are both Computer Science Majors at St. Norbert College The Project was really chosen as a way to become familiar with Flash and the art that is Event Programming! Prior to this project, neither of us really had any experience in either field. Event Programming is a course offered here at St. Norbert College. You can find more information online or from one of the Computer Science Professors (Dr. McVey)

  3. Presentation Outline • Event-Driven Programming • What is it? • How did it come about? • How does it work? • Macromedia Flash (Adobe) • What is it? • What is it used for today? • What is ActionScript? • ActionScript and Event-Programming

  4. Presentation Outline Continued • Sample Code • A general look at ActionScript inside Flash • Some of our code • What this means for the capabilities of Flash • Code and Flash creations combined!

  5. Event-Driven Programming • Event Programming is a computer programming method used to help the computer interact with the environment. • Most programs are structured to only change data flow given certain branching points, but the flow of the event program depends upon actions going on in the outside world. • Everything from the click of your mouse, scrolling over an object with your mouse, entering data, and calling the time can be turned into an event. • Much of the graphical interface we see has been set up to respond to events. • Each window you open has the minimize, restore, and close options in the top right corner. Your computer is constantly searching for a mouse click in one of those areas. Once one is received, the chosen result takes place!

  6. History • During the 1970's, the typical computer system was a batch processing system. Input data was typically a sequential file on tape. • A program reads data from the input file, processed it, and wrote the results out to another sequential file. That file, in turn, was processed by another program and written out to another file, which in turn was processed by another program, and so on. • The standard model of a computer system was an assembly line. Raw materials come in one door; they are processed, processed, processed; and at the end of the processing, a finished product is pushed out another door. This mental model underlay the "structured" systems development methods. • Today we can think of the processor as a spider web. Data can be passed freely from location to location, shattering the capabilities of old.

  7. History Continued • The top figure represents the structured computer design of old. It was basically a singular data path that ran forward like a giant pipeline. The bottom figure shows how the data structure has changed into that of a transaction. A transaction occurs when any piece of data, signal, control, or event is sent to the transaction center to be processed.

  8. So How Does It Work? • Event Loops are used by the system to continuously look for a certain action or information to be sent. Certain events such as the time of day could also be used to set off an event. To program an event driven system one must rewrite the default trigger functions of the system, to match the desired behavior. • The method by which information on events is acquired by the system doesn't matter. Inputs can be polled (continuously checked) within the event loop, to determine if part of the system is ready to send of receive data. Also, interrupt handlers can be registered to react to hardware events. Many systems will use a mixture of both techniques.

  9. So How Does It Work? Continued • Event-driven programs consist of a few parts: • Dispatcher – receives events and determines which handlers can deal with an event of that type • Loops so that it can continuously handle incoming events • An event queue may be used to store events waiting to be dispatched • Event Handlers – called by the dispatcher, execute a portion of the program based on the event sent to it • In some cases, event handlers may trigger other events themselves leading to an event cascade – a difficult problem to fix

  10. Inner Workings The Dispatcher: 1. Receives the data, event, etc. 2. Analyzes the transaction type 3. Dispatches the type of transaction 4. Completes the transaction process

  11. Inner Working Continued • Applications can either treat event streams as infinite or finite. • A typical use for infinite event streams is in an application that controls hardware. The application searches for events concerning that hardware anytime the computer is running. • Most other event handling applications use a finite event stream. The stream is opened when the application is launched and proceeds until a special event occurs. Examples of such special events are: • Keyboard key pressed (ESC, Enter) • A particular mouse click within the application • Clicking a CLOSE button in GUI (think X in Windows) • There are some events that a dispatcher may not have an assigned handler for. These situations can either be ignored, or an exception can be raised. • For example, GUI applications are concerned mostly with the clicking of the mouse, but not with the pointer movement. Movement events are typically ignored in GUI applications

  12. More Inner Workings • Event-driven programming aims to be as asynchronous as possible. That is, the program is not dependant on the clock or particular time of day. • Operating systems are a very common use of event-driven programming. The graphical interface of most operating systems responds to several types of events. • Mouse clicks • Text Entered • Shortcut keys pressed • Operating systems also typically act as dispatchers for software processes, passing data and software interrupts to user processes that in many cases are programmed as event handlers themselves.

  13. With All That In Mind….! • We will now move into an environment that allows us to use event programming through the use of graphical user interface. • Various event-driven programming environments include: • Flash (w/ ActionScript) • MFC • C++ • Visual Basic • Java

  14. Macromedia (Adobe) Flash • Macromedia Flash (which is now actually Adobe Flash and long before that FutureSplash) is a multimedia authorizing program used to create web applications, games, and movies. The Flash Player is available in most web browsers. It has high quality graphics and is backed by its own programming language called ActionScript. ActionScript is what Flash makers use to make just about all of the interactive elements you see such as buttons, text entry fields, and pick lists. • Flash itself is an integrated development environment or IDE whereas Flash Player is used to run the Flash files. Since its development in 1996, Flash has become very popular for adding animation and an interactive element to web pages, such as Homestarrunner.com. Most of the time you will see Flash used on advertisements, and other things that use videos on web pages. The interactive element is where we, the event programmers come into the picture!

  15. Flash Site • Here we see pictures from HomeStarRunner.com • Everything is made in Flash! • Each side menu triggers an event by merely being scrolled over. • Scrolling over downloads made (Pan-Pan) the panda fall where being over store triggers the blue hair on HomeStar! • Some events such as download trigger an uninterruptible event such as the one on the far right with Stinkoman

  16. Flash (Good or Evil?) • Today, just about all the hot sites on the internet use Flash. Just take a look at YouTube! This internet giant grew to a billion dollar worth in a little over a year. Not only is Flash responsible for the easy play access to the some 100 million plus users, but it has revolutionized the entertainment industry as a whole. In reality, about 98% of the people using the internet in the US have FlashPlayer installed. • Compared to other net plug-ins such as Java, Acrobat Reader, QuickTime, and Windows Media Player, Flash Player has a fast install and initialization time. Vector graphics along with program code such as ActionScript allow Flash files to be very small bandwidth users as compared to bitmaps and other video clips. The nice thing about Flash is its flexibility to allow many different kinds of video display. If you're going to be watching specifically video clips, other web players might be more attractive, but they can't compare to the overall flexibility of Flash. • The popularity of Flash also leads to problems. Many popup sites and banner advisements utilize Flash to create eye catching graphics since most of the population will be able to view them.

  17. NOOOOOO!!!

  18. ActionScript • ActionScript is an JavaScript-based programming language that is used for Flash movies and applications. While Java is mostly used for browser windows, documents, and form centric, ActionScript is movie centric, and that may include animations, audio, text, and event handling. • In ActionScript 2.0 there can be classes, and also, a library item (a MovieClip) can be associated with a class. Classes are always written in external text files, and these files must have the .as extension. Classes are extensions to the ActionScript language which the programmer can write him/herself, though there are many built-in classes such as the MovieClip class, which can be used to draw vectors onto the screen dynamically. Class files can be used to make your programming easier, and the class files can be transferred between many projects if needed.

  19. ActionScript • Flash and ActionScript allow you to assign code to specific objects such as graphics, buttons, movie clips, or an entire frame. Flash checks all of the syntax on your code and also contains a large library of functions you can call. • There are many ActionScript tutorials and resources on the internet. If you are interested in event-programming using Flash, we suggest you look there. You can find basic tutorials in our project website and links to external resources on the “About Us” page.

  20. Making Event-Driven Flash Creations • Programming in Flash is quite simple. Even a beginner can create something useful in a few seconds – all they need to know is a few lines of code and how to access menus in Flash. • Creating an object and converting it to a button takes only a matter of seconds. • After a button is made, ActionScript can be added to it so that it takes action within the given flash application.

  21. What About Moving Things? • Each object you make has the ability to move around in the Flash environment given the correct ActionScript coding • In the Ship Game we created, not only can you move the ship, but the image for the ship is rotated depending on which arrow direction you press. • We also added two other objects that follow our ship around. By giving them ActionScript to follow the ship object, they will try to move to the same location as the ship. ActionScript was added so that if the ship touches one of these objects, the life bar for the ship that drops. When the life bar reaches zero, the game is over and you are given the option to restart the game from frame 1.

  22. What About Using The Time? • As stated previously, the computer’s internal clock can be used to trigger events. Using the time is one of the few synchronous processes in event programming. • In our example we simply made a text box that holds dynamic text. From here we have it the instance name of disp so the Actionscript that got the time on the frame could link the two together. • From there, we just built a little picture around the text, set it to 00:00:00, and changed the text color to look like a real digital clock might.

  23. Examples In Action • For further elaboration on the topics we discussed here along with all our examples, test code, and even tutorials on how to make your own Flash applications, visit our project web page. • In reality, these examples might look simple, but they are very, very time consuming to construct. • We have really only just touched on what Flash in capable of using ActionScript. In CSCI-350 (Event Programming) you will be able to get a better feel for how everything really works. • Please feel free to email either of us if you have questions or comments. It would be more than appreciated. Thanks

  24. Sources Used • http://en.wikipedia.org/wiki/Event-driven_programming • http://en.wikipedia.org/wiki/Macromedia_Flash • http://en.wikipedia.org/wiki/Actionscript • http://cooltext.com/ • http://www.newgrounds.com/collection/flashtutorials.html • http://eventdrivenpgm.sourceforge.net/ • Macromedia Flash MX 2004 Bible by Robert Reinhardt and Snow Dowd • The Web Wizard's Guide to Flash by Michael R. Kay • ActionScript for Flash MX Pocket Reference by Colin Moock

More Related