750 likes | 923 Views
COM531 Multimedia Technologies. Lecture 7 – Flash AS and Flash Catalyst. What is Interactivity?. Automated response to user activity Example applications Reactive elements Simulations Tutorials Quizzes Interactivity in Flash: Events call actions to be performed on targets
E N D
COM531 Multimedia Technologies Lecture 7 – Flash AS and Flash Catalyst
What is Interactivity? • Automated response to user activity • Example applications • Reactive elements • Simulations • Tutorials • Quizzes • Interactivity in Flash: • Events call actions to be performed on targets • Defined using ActionScript
Managing Flash Projects • Scenes • Divide timeline into manageable sections e.g. Introduction, conclusion, index, etc. • Useful for long/complex movies • Libraries • Organise assets using folders • Share assets between projects • e.g. logos, audio/video • Movie Explorer • Overview of project structure • Access and edit assets
Testing Flash Movies • Bandwidth profiler • Test delivery with differentbandwidths • Identify download delays • Show streaming • Debug Movie • For validating complex scripts • Real time values for variables, movie clip properties… • Test manually • Different platforms and browsers • Different connections (e.g. modem)
Publish Settings • Select formats for publication • Range of formats supported • Flash, HTML, GIF, QuickTime… • Configure settings for each format • Filenames • Alignment • Size • Looping • Quality • Publish preview for each format • Test appearance and functionality
Publish as HTML • HTML is native language of web • Flash can automatically create HTML • Based on range of built-in templates • HTML produced not always appropriate • Change HTML of each page • Manually or with an authoring tool • Customise Flash templates • Affects all published pages
Flash Accessibility • Web content should be accessible to all users • Regardless of ability/disability • Issues • Visual, time-based media not suitable for all users • Requires Flash player (plug-in) • Limited support for screenreaders • Benefits • Animation can be more accessible to some users • Supports multiple media (audio, video, text…) • Vector graphics scale without deterioration • Allows keyboard access • Player ensures cross-platform consistency
Improving Accessibility • Provide text equivalents in HTML • For entire movie using [d]link • Provide text equivalents in Flash • Increases accessibility to screen readers • Specific software required to process • Only for movie clips • Provide keyboard controls to movies (play, stop…) • Publish movie content in range of formats • Images, text, audio/video…
Object-Oriented Scripting • ActionScript is an object-oriented scripting language • Scripting languages organise information into groups called classes • Classes and objects are just ways to group together chunks of information
Terminology • Class • Instance • Object
Classes & objects • Classes are groups of objects that share characteristics, e.g. rectangles • Shared characteristics allow you to create a blueprint for those objects • A software blueprint for an object is called a class
Object-Oriented Scripting You can create multiple instances of these classes, which are called objects Real-world analogy: “Bicycle" class You can have many objects of the same kind (e.g. A bicycle, your bicycle is just one of many bicycles in the world) Using object-oriented terminology, we say that your bicycle object is an instance of the class of objects known as bicycles
Object-oriented terminology Class: Defines the common characteristics of a bicycle. Like a plan Objects: Physical manifestation of bicycle class. Each object is a instance of the bicycle class
Instances Using the bicycle class, you can create any number of bicycle objects from the class When you create an instance of a class each instance gets its own copy of all the instance variables defined in the class
Classes & objects • Bicycles have states (current gear) • Bicycles have behaviors (change gears, brake) in common However, each bicycle's state is independent of and can be different from that of other bicycles
Objects vs. Classes • Objects and classes seem very similar • In the real world, it's obvious that classes are not themselves but the objects they describe • A blueprint of a bicycle is not a bicycle
Classes & objects • Classes are groups of objects that share characteristics i.e. software blueprint • Object is the physical manifestation of a class • Each object is an instance of the class
Action Script Script applied to an action Basic structure of an action whenSomethingHappens (input variables) { do stuff }
Target Event on (press) { setProperty ("MyTarget", _height, "100"); } 100 Action MyTarget 50 MyTarget ActionScript • Scripting language used in Flash to create advanced interactivity and animation • Allows the execution of different actions in a movie depending on what a user does or on what frame of the movie is being played • Similar structure and syntax to JavaScript • Example script:
Creating ActionScript • Does not require: • Detailed understanding of language • Hand-coding of scripts • Actions panel • Graphical interface to ActionScript • Build custom scripts using pre-written pieces of code • Define events, targets and actions • Scripts are validated automatically
Actionscript Fundamentals • ActionScript is a programming language • Subject to usual programming language constraints • Has its own syntax and structure
Some uses of ActionScript • Create multiplayer games • Create engaging, user-aware navigation • Send data to middleware, like PHP and Cold Fusion • Communicate with JavaScript
Benefits of using ActionScript • Allow for a more responsive Web site • Allows inclusion of dynamic data • Make your site more accessible to readers
ActionScript limitations • ActionScript can't talk directly to a database. Middleware like PHP, Cold Fusion, or ASP is needed to do this.** • Can't use exception handling i.e. try, throw, or catch (Error handling in Javascript) • Exceptions provide error-handling capabilities for programs. An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions **This functionality can now be achieved using Macromedia Flash Remoting
ActionScript Functionality Two ways to add ActionScript to Flash movie • Frame Actions – code associated with particular keyframes of the movie • Custom classes – code that resides in an external file • Flash component interactions create events and the associated actions are programmed as event handler functions • Event model used is DOM2, so event handlers are registered with addEventListener
Events • Events call an action • Dependent on user activity or autonomous • Single event can trigger multiple actions • Mouse events • Mouse movement, button clicks • Keyboard events • Keystrokes, text entry • Frame events • Occur automatically on entering frame • Attached to timeline of movie or movie-clip
Actions • Wide range of pre-defined actions • Movie control • Stop, play, go to frame, etc. • Movie Clip control • Set property, play/stop, etc. • Parameters can be customised • Actions can be: • Performed on multiple targets • Conditional (If, then, else…)
myTarget2 myTarget3 myTarget1 Targets • Target is object on which action is performed • Current movie • Movie-clip instances • External applications – e.g. browsers • Defining targets • If no target defined action affects current object • Movie clip instances require unique name • Define path from current object to target
Learning Interactions • Templates for creating interactive assessment • Range of question types available • MCQ, drag-and-drop, hotspot, etc. • Parameters can be customised • Question, answers, feedback, etc. • Use Clip Parameters panel • Submissions can be tracked • Data sent to LMS • Quiz templates • Integrate a set of learning interactions
Action Buttons • Means of providing movie controls • e.g. Play, Stop, Rewind • Button states • Pre-defined keyframes in timeline • Can contain layers, animation, images, etc. • Built-in actions can be attached to buttons • Range of button sets provided by Macromedia
Object and Frame Actions Two basic kinds of actions in Flash • Object actions • Frame actions
Object Actions - Movie Clips • Object actions are chunks of ActionScript code that are attached to an object • Usually an object is a symbol that is either a button or a movie clip • Graphic symbols don’t have actions
Object Actions An object action is associated with an instance of a symbol, not with the symbol itself
Object Actions Both shapes are instances of the same movie clip symbol, but only one of them has an action attached to it The function is always attached to this object instance, no matter where in the movie it appears Object actions aren’t concerned with what frame the movie is currently on (as long as the object actually exists in the movie at that frame)
Event handlers The function you saw was a “onClipEvent” and is known as an event handler An event is something that happens: i.e. a movie loads, user presses a mouse button An event handler constantly looks for events and lets ActionScript know when one of them occurs
Typical Event handler • OnmouseDown refers to what the mouse button is doing • If mouse button was pressed, then onClip-Event(mouseDown) is called, and everything inside the first set of curly braces is executed OnmouseDown { startDrag(this); }
Methods • startDrag is what's called a method • A method does something In this case drag what was clicked
Methods A method is something an object can do or something you can do to an object. For example, here are some things methods can do: • Stop a movie clip • Go to a certain frame and start playing there • See if a movie clip is over another movie clip • Hide the mouse cursor • Set the volume of a sound being played
Targets • Notice that we didn't use startDrag(), but used startDrag(this). • The startDrag method requires a target i.e., it needs to know what it should start dragging
“this” command • The easiest way to reference the current object is just to call it “this” • The other way to refer to the object is absolute i.e. startDrag(_root.drag_fish) • Where drag_fish is the name of the instance of the fish symbol • The _root part means "start looking from the top of the movie hierarchy"
Object actions: onClipEvent Object actions on a movie clip have to be inside of an onClipEvent. Possible events are: • load • unload • enterFrame • mouseMove • mouseDown • mouseUp • keyDown • keyUp
Object Actions: Buttons The only real difference between actions that are attached to buttons instead of movie clips is that the event handler for buttons is “on” instead of onClipEvent Otherwise, they're pretty much the same
Object Actions Buttons The events for on are: • press • release • releaseOutside • rollOver • rollOut • dragOver • dragOut • keyPress