Multimedia Authoring COM315 - PowerPoint PPT Presentation

1 / 58
About This Presentation
Title:

Multimedia Authoring COM315

Description:

ActionScript is the scripting language used in Adobe Flash to create advanced ... Allows the execution of different actions in a movie depending on what a user ... – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 59
Provided by: ISGr7
Category:

less

Transcript and Presenter's Notes

Title: Multimedia Authoring COM315


1
Multimedia Authoring COM315
  • Week 9
  • Actionscript

2
Timetable 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

3
Submission Deadlines
  • Assignment 2 11/12/09 (Week 12)
  • Assignment 3 10/12/09 (Week 12)

4
Introduction to Actionscript
  • What is ActionScript?
  • What is ActionScript good for?
  • What ActionScript can't do
  • Object orientated programming
  • Elements of programming in Actionscript

5
What 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

6
Some uses of ActionScript
  • Create multiplayer games.
  • Create engaging, user-aware navigation.
  • Send data to middleware, like PHP and Cold
    Fusion.
  • Communicate with JavaScript.

7
Benefits of using Actionscript
  • Allow for a more responsive Web site.
  • Allows inclusion of dynamic data
  • Make your site more accessible to readers.

8
ActionScript 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

9
Actionscript 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.

10
Object-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

11
Terminology
  • Class
  • Instance
  • Object

12
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.

13
Object-Oriented Scripting
  • You can create multiple instances of these
  • classes, which are called objects.
  • Real-world analogy Bicycle" class

14
Classes 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.

15
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
16
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.

17
Instances
18
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.

19
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

20
Objects vs. Classes
21
Class Instances in Flash
22
Class Instance in Flash
23
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

24
Actionscript Fundamentals
  • Actionscript is a programming language
  • Similar to lingo
  • Subject to usual programming language constraints
  • Has its own syntax and structure

25
Action Script
  • Script applied to an action
  • Basic structure of an action
  • whenSomethingHappens (input variables)
  • do stuff

26
Object and Frame Actions
  • Two basic kinds of actions in Flash
  • Object actions
  • Frame actions

27
Object 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

28
Object and Frame Actions
29
Object Actions
  • An object action is associated with an instance
  • of a symbol, not with the symbol itself.

30
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 arent concerned with what frame
    the
  • movie is currently on (as long as the object
    actually
  • exists in the movie at that frame)

31
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.

32
Event handlers
33
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)

34
Object Actions Drag fish
35
Methods
  • startDrag is what's called a method.
  • A method does something.
  • In this case drag what was clicked.

36
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.

37
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.

38
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."

39
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

40
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.

41
Object Actions Buttons
  • The events for on are
  • press
  • release
  • releaseOutside
  • rollOver
  • rollOut
  • dragOver
  • dragOut
  • keyPress

42
Object Actions Buttons
43
Object Actions Buttons
44
Frame 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.

45
Frame Actions
46
Frame Actions
47
Frame Actions
  • Frame actions only allowed on a keyframe!!!
  • Hint Place all of your frame actions on a
  • separate layerit makes organization easier

48
Summary
  • Two basic kinds of actions in Flash
  • Object actions (Movie clips and buttons)
  • Frame actions

49
Actionscript 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

50
Dot 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

51
Relative Absolute Paths
52
Root 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.

53
Root Properties
  • Its analogous to an absolute URL You start at
  • the top and specify your way down

54
Properties
  • 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)

55
Properties
  • 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

56
underscore (_)
  • All movie clip properties start with an
  • underscore (_)
  • That's just how Flash is

57
Summary
  • Actionscript is an object orientated programming
    language used in Flash.
  • Applied to objects (movie clips buttons)
    frames
  • Event driven

58
Multimedia Authoring COM315
  • Week 9
  • Actionscript
Write a Comment
User Comments (0)
About PowerShow.com