200 likes | 415 Views
Flash Basics. Actionscripting. Types of Symbols. Button Allows user interactivity Has a 4 state timeline: up, over, down, hit Timeline independent of main scene timeline Graphic Contains graphical information No user interactivity Timeline pegged to main scene timeline Movie Clip
E N D
Flash Basics Actionscripting
Types of Symbols • Button • Allows user interactivity • Has a 4 state timeline: up, over, down, hit • Timeline independent of main scene timeline • Graphic • Contains graphical information • No user interactivity • Timeline pegged to main scene timeline • Movie Clip • Contains graphical information • Can respond to user and • Can be responsive to programming • Timeline independent of main scene timeline
Symbols • Symbols live in the Library • Each version of a symbol on the stage is an INSTANCE. • Visual Changes made to symbols in the library will globally affect every instance of it on the stage. • Each instance must be named in order to make it interactive. • Each instance can be graphically modified in these ways: color tint, transparency, and size. • Movie clip instances can also change their skew, rotation, filter, and do basic blending modes.
You can import photos into Flash • File>Import to Library> choose the photoshop, jpg, gif or tif file • It appears in library as a graphical symbol • Layered images will import as a set of graphical images or can import as a keyframed animation • You can import illustrator files the same way
Flash uses Actionscript 3.0 • This is a programming language • A program is a series of instructions or steps for the computer to carry out. • Each step ultimately involves manipulating some piece of information or data. • a computer program is just a list of step-by-step instructions that you give to the computer, which it performs one by one. • Each individual instruction is known as a statement. • in ActionScript, each statement is written with a semicolon at the end. • Stop();
Variables • Programming mainly involves changing pieces of information in the computer’s memory so there needs to be a way to represent a single piece of information in the program. • a variable actually consists of three different parts: • The variable’s name (weather) • The type of data that can be stored in the variable (snow, rain, sun, sleet) • The actual value stored in the computer’s memory (sleet)
Variable • The name (weather) is a placeholder for the value. • The data type is also important. When you create a variable in ActionScript, you specify the specific type of data that it will hold; from that point on, your program’s instructions can store only that type of data in the variable • In ActionScript, to create a variable (known as declaring the variable), you use the var statement: var todaysDate:Number; var weather:String;
Simple Data Types var todaysDate:Number; var weather:String; •String: WORDS a textual value, like a name or the text of a book chapter •Numeric: ActionScript 3.0 includes three specific data types for numeric data: Number: any numeric value, including values with or without a fraction int: an integer (a whole number without a fraction) uint: an “unsigned” integer, meaning a whole number that can’t be negative •Boolean: a true-or-false value, such as whether a switch is on or whether two values are equal or is today a Friday?
Complex Data Type • What kinds of stuff does the computer think about? there are many data types that you can use as the data type of the variables you create • Most of the built-in data types, as well as data types defined by programmers, are complex data types. Some of the complex data types you might recognize are: • MovieClip: a movie clip symbol • TextField: a dynamic or input text field • SimpleButton: a button symbol • Date: information about a single moment in time (a date and time)
Text Types • Static: a picture of text • Dynamic: text that can change its value based on programming commands • Input: text that the user can change, words and numbers can be input in the system to change what it does.
Class and Object • Two words that are often used as synonyms for data type are class and object • Actionscript is an Object Oriented language, meaning you describe an object and give it tasks to do or respond to.
More on the Movie Clip data type • Common movie clip tasks. • Making movie clips play and stop • Playing movie clips in reverse • Moving the playhead to specific points in a movie clip’s timeline • Working with frame labels in ActionScript • Accessing scene information in ActionScript • Creating instances of library movie clip symbols using ActionScript • Loading and controlling external SWF files, including files created for previous Flash Player versions • Building an ActionScript system for creating graphical assets to be loaded and used at run time
Characteristics of the movie clip • There are various characteristics of the movie clip that you can modify. • For example, when it’s selected there are values you can change in the Property inspector, like its x coordinate, or its width, or various color adjustments like changing its alpha (transparency), or applying a drop-shadow filter to it. • Other Flash tools let you make more changes, like using the Free Transform tool to rotate the rectangle. • All of these things that you can do to modify a movie clip symbol in the Flash authoring environment are also things you can do in ActionScript by changing the pieces of data that are all put together into a single bundle called a MovieClip object.
Class characteristics • In ActionScript object-oriented programming, there are three types of characteristics that any class can include: • Properties • Methods • Events • Together, these elements are used to manage the pieces of data used by the program and to decide what actions are carried out and in what order.
Properties • Of a human (class=human) • Hair color? Eye color? Gender? Height? MovieClip class has properties like rotation, x, width, and alpha.
Method • A method is an action that can be performed by an object. • Object Class = dog • Methods are: bark, eat, run, jump • If a movie clip symbol in Flash has several keyframes and animation on its timeline, that movie clip can play, or stop, or be instructed to move the playhead to a particular frame.
Events & event handling • Events are things that happen that ActionScript is aware of and can respond to. • The technique for specifying certain actions that should be performed in response to particular events is known as event handling
Event handling: three important elements • there are three important elements you’ll want to identify: • The event source: Which object is the one the event is going to happen to? For instance, which button will be clicked? The event source is also known as the event target, because it’s the object where the event is targeted (that is, where the event actually happens). • The event: What is the thing that is going to happen, the thing that you want to respond to? This is important to identify, because many objects trigger several events. MouseEvent.CLICK • The response: What step(s) do you want performed when the event happens? What happens?
In your completed animation • Add a stop frame and a gotoandPlay button • Also, do the Zack button tutorial
Button Code from last week stop(); blue_btn.addEventListener(MouseEvent.CLICK, myFunction); function myFunction(e:MouseEvent):void { gotoAndStop("frame30"); } purple_btn.addEventListener(MouseEvent.CLICK, myOtherFunction); function myOtherFunction(e:MouseEvent):void { gotoAndPlay("frame30"); } red_btn.addEventListener(MouseEvent.CLICK, myredFunction); function myredFunction(e:MouseEvent):void { gotoAndStop("frame 1"); }