Title: Multimedia Authoring COM315
1Multimedia Authoring COM315
2Timetable weeks 9-10-11-12
- Week 9
- Lecture Actionscript
- Lab Flash
- Week 10
- Lecture Assignment 1 Feedback
- Lab Flash
- Week 11
- Lecture Assignment 1 feedback/ Class Test
Revision /Web design - Lab Flash/Actionscript
- Week 12
- Lecture Class test
- Lab Flash/Actionscript/Assignment help
3Submission Deadlines
-
- Assignment 2 11/12/09 (Week 12)
- Assignment 3 10/12/09 (Week 12)
4Introduction to Actionscript
- What is ActionScript?
- What is ActionScript good for?
- What ActionScript can't do
- Object orientated programming
- Elements of programming in Actionscript
5What Is ActionScript?
- ActionScript is the scripting language used in
Adobe 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 in structure to Javascript
6Some uses of ActionScript
- Create multiplayer games.
- Create engaging, user-aware navigation.
- Send data to middleware, like PHP and Cold
Fusion. - Communicate with JavaScript.
7Benefits of using Actionscript
- Allow for a more responsive Web site.
- Allows inclusion of dynamic data
- Make your site more accessible to readers.
8ActionScript limitations
- ActionScript can't talk directly to a database.
Middleware like PHP, Cold Fusion, or ASP is
needed to do this. - This functionality can now be achieved using
Adobe Flash Remoting
9Actionscript limitations
- 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.
10Object-Oriented Scripting
- ActionScript is an object-oriented scripting
language - Scripting languages organize information into
groups called classes. - Classes and objects are just ways to group
together chunks of information
11Terminology
12Classes 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.
13Object-Oriented Scripting
- You can create multiple instances of these
- classes, which are called objects.
- Real-world analogy Bicycle" class
14Classes objects
- 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.
-
15Object-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
16Instances
- 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.
17Instances
18Classes 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.
19Objects 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
20Objects vs. Classes
21Class Instances in Flash
22Class Instance in Flash
23Classes 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
24Actionscript Fundamentals
- Actionscript is a programming language
- Similar to lingo
- Subject to usual programming language constraints
- Has its own syntax and structure
25Action Script
- Script applied to an action
- Basic structure of an action
- whenSomethingHappens (input variables)
- do stuff
26Object and Frame Actions
- Two basic kinds of actions in Flash
- Object actions
- Frame actions
27Object Actions - Movie Clips
- Object actions are chunks of ActionScript code
that are attached to an object - Usually an object is a symbol that's either a
button or a movie clip. - Graphic symbols dont have actions
28Object and Frame Actions
29Object Actions
- An object action is associated with an instance
- of a symbol, not with the symbol itself.
30Object 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 arent concerned with what frame
the - movie is currently on (as long as the object
actually - exists in the movie at that frame)
31Event 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.
32Event handlers
33Typical 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)
-
34Object Actions Drag fish
35Methods
- startDrag is what's called a method.
- A method does something.
- In this case drag what was clicked.
36Methods
- 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.
37Targets
- 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.
38this 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."
39Object 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
40Object 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.
41Object Actions Buttons
- The events for on are
- press
- release
- releaseOutside
- rollOver
- rollOut
- dragOver
- dragOut
- keyPress
42Object Actions Buttons
43Object Actions Buttons
44Frame Actions
- Frame actions are like object actions, except
that the actions are associated with a certain
spot in the timeline instead of an object. - If a frame has some actions associated with it,
those actions are carried when the playhead
enters that frame.
45Frame Actions
46Frame Actions
47Frame Actions
- Frame actions only allowed on a keyframe!!!
- Hint Place all of your frame actions on a
- separate layerit makes organization easier
48Summary
- Two basic kinds of actions in Flash
- Object actions (Movie clips and buttons)
- Frame actions
49Actionscript Syntax
- ActionScript uses what is called dot syntax.
- For example, if you have a movie clip called
- red_shirt inside of the movie clip called
- santa_claus, then one way to access that
- object is
- _root.santa_claus.red_shirt
50Dot Syntax
- To write paths actionscript uses what is called
dot syntax. - E.g. to access the movie highlighted the path
would be -
- _root.movieClip_one.clip_a.square1
51Relative Absolute Paths
52Root Properties
- _root is the base of all Flash movies. If you
- want to find out where red_shirt is on the stage,
- you could use
- xPosition _root.santa_claus.red_shirt._x
- _x is a property that returns the horizontal
position of the object.
53Root Properties
- Its analogous to an absolute URL You start at
- the top and specify your way down
54Properties
- A property is an attribute of an object. Movie
clip - examples include
- how wide it is (_width)
- where it is on the stage (_x and _y)
- what frame is currently being played
(_currentframe) - how transparent it is (_alpha)
- its name (_name)
- whether it's visible or not (_visible)
55Properties
- Most properties can be read or altered. For
- example, let's see how wide a movie clip called
- clue is
- _root.clue._width 110
- _root.clue._width 40
56underscore (_)
- All movie clip properties start with an
- underscore (_)
- That's just how Flash is
57Summary
- Actionscript is an object orientated programming
language used in Flash. - Applied to objects (movie clips buttons)
frames - Event driven
58Multimedia Authoring COM315