MovieClips & Properties Flash ActionScript Introduction to Thomas Lövgren

Slides:



Advertisements
Similar presentations
1What is the Stage. 2How do you open a panel in Flash
Advertisements

CIS 205—Web Design & Development Flash Chapter 3 Appendix B on Creating Animations.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 18 – Macromedia Flash MX 2004: Building an Interactive Game Outline 18.1 Introduction 18.2 Object-Oriented.
Macromedia Flash MX 2004 – Design Professional and Interactivity WORKING WITH SYMBOLS.
© Anselm Spoerri Lecture 11 Flash –Build Flash Website with Animated Navigation Structure –Decide on Overall Navigation Layout, Import Images & Organize.
Work with symbols and instances Work with Libraries Create buttons Assign actions to buttons Unit Lessons.
1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language.
Events (Listeners/Handlers: Mouse, keyboard, timer) Flash ActionScript 3.0 Introduction to Thomas Lövgren, Flash developer
© 2010 Delmar, Cengage Learning Chapter 4: Creating Animation.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 9 "The games of a people reveal.
© 2011 Delmar, Cengage Learning Chapter 8 Building Complex Animations.
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
Animations Flash ActionScript Introduction to Thomas Lövgren
Chapter 3 Working with Symbols and Interactivity.
Introduction to Flash FYS100 Creative Discovery in Digital Art Forms Spring 2007 Burg.
Chapter 4 Creating Animations.
© 2011 Delmar, Cengage Learning Chapter 9 Introduction to ActionScript 3.0.
Interface & navigation (How to build a simple presentation interface) Flash ActionScript Introduction to Thomas Lövgren
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
Working with Symbols and Interactivity
© 2010 Delmar, Cengage Learning Chapter 3: Working with Symbols and Interactivity.
CSC 361/661 Digital Media Spring 2010 Professor Burg.
Getting a handle on ActionScript A basic primer for non-programmers.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 2 "The games of a.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 3 "The games of a.
XP Tutorial 4 Special Animations. XP New Perspectives on Macromedia Flash MX Special Layers for Animation Animation Using a Motion Guide Layer.
Adobe Flash CS3 Revealed Chapter 3 - WORKING WITH SYMBOLS AND INTERACTIVITY.
More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg.
Introduction to Flash MX 2004: Action Scripting Lloyd Rieber.
CSC 361/661 Digital Media Spring 2010 Professor Burg.
INTRO TO ACTIONSCRIPT 3.0 The Bad News: Learning ActionScript is as Much Fun as Being Torn Apart By a Pack of Crazed Wombats. (And I say that in a loving.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script "The games of a people reveal.
© 2011 Delmar, Cengage Learning Chapter 4 Creating Animations.
Chapter 4 Creating Animations. Chapter 4 Lessons 1.Create motion tween animations 2.Create classic tween animations 3.Create frame-by-frame animations.
Motion Tweening – Lesson 81 Motion Tweening Lesson 8.
Mouse Events & Keyboard Inputs Flash ActionScript Introduction to Thomas Lövgren
Flash CS 5 Interface BY NSCHEWCZYK | ©2012. MENU BAR A bar at the top of the window. It lists menu options including: File, Edit, View, Insert, Modify,
Distributed Multimedia Programming Week – 4A Buttons Movie Clips.
CISC 110 Day 5 OOP Part 2. 2 Outline The Display List Display List Classes Adding and Removing Objects Adding Symbol Instances Managing Object Depths.
© Anselm Spoerri Lecture 10 – Related: Part 1 Flash –Build Flash Website with Animated Navigation Structure –Decide on Overall Navigation Layout, Import.
Building the Events Components– Lesson 111 Building the Events Components Lesson 11.
Introduction to Flash CSC361/661 Digital Media Spring 2007 Burg.
Macromedia Flash 8 Revealed WORKING WITH SYMBOLS AND INTERACTIVITY.
Macromedia Flash Design Professional And Interactivity WORKING WITH SYMBOLS.
© 2011 Delmar, Cengage Learning Chapter 10 Using ActionScript to Enhance User Experience.
1 Actionscript for Flash by Dr SC Li. 2 Understanding more about instances Symbolsgraphics buttons Movie clips Instances (without names) No interaction.
Tutorial 3 Creating Animations. XP Objectives Learn the different elements of animation Create frames and layers Organize frames and layers using the.
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
Video in Macromedia Flash (Optional) – Lesson 121 Video in Macromedia Flash (Optional) Lesson 12.
CIS 205—Web Design & Development Flash Chapter 3 Appendix on Using Buttons.
INTRO TO ACTIONSCRIPT 3.0 The Bad News: Learning ActionScript is as Much Fun as Being Torn Apart By a Pack of Crazed Wombats. (And I say that in a loving.
Open a new Flash File Action Script 2.0. Create a button like you did last lesson and name it Click to Play.
XP Tutorial 3 Creating Animations. XP New Perspectives on Macromedia Flash MX Elements of Animation Layers are used to organize the content of.
Intro to ActionScript CIS 126 Greg Shorts. What Is ActionScript? ActionScript is the scripting language Flash uses to control its movies and the objects.
DM 11- Flash –Unit C and Interactivity WORKING WITH SYMBOLS.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
CIS 205—Web Design & Development Flash Chapter 3 Working with Symbols and Interactivity.
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script "The games of a people.
Macromedia Flash MX Design Professional And Interactivity WORKING WITH SYMBOLS.
CDM105 Session 12 Macromedia FLASH MX 2004 Part 5 : Sounds, publishing your movies, and the ‘Get URL’ action.
 Movieclip symbols are reusable pieces of flash animation  consisting usually of one or more graphic/button symbols  thus they are flash movies within.
Tutorial 3 Creating Animations.
ActionScript Basics 2016 (2.0 – 3.0)
Flash Demonstration – Unit 5 – ActionScript 2.0
Unit Lessons Work with actions
CT1514 Flash-2.
Animate Some more advanced concepts
Working with Symbols and Interactivity
MovieCLip Instances & ActionScript
Flash Demonstration – Unit 5
Presentation transcript:

MovieClips & Properties Flash ActionScript Introduction to Thomas Lövgren

MovieClips The MovieClip class is the template for all the properties, methods & events that are part of a MovieClip object The MovieClip class is the template for all the properties, methods & events that are part of a MovieClip object When we create a movie clip, the new instance will inherit properties, methods & events from the MovieClip class When we create a movie clip, the new instance will inherit properties, methods & events from the MovieClip class Every MovieClip object has a timeline (playing independently of the main timeline) Every MovieClip object has a timeline (playing independently of the main timeline) We can move the playhead to a specific point or frame in the MovieClip Timeline We can move the playhead to a specific point or frame in the MovieClip Timeline The Display Properties describes a MovieClip Object’s form The Display Properties describes a MovieClip Object’s form MovieClips could be placed inside each other (nested), which also makes them useful for complex animations MovieClips could be placed inside each other (nested), which also makes them useful for complex animations

Creating MovieClips There are basically two ways of creating a movieClip: There are basically two ways of creating a movieClip: Manual: Create a MovieClip symbol (library item) Manual: Create a MovieClip symbol (library item) Dynamic: MovieClip created by code Dynamic: MovieClip created by code Note! The new instance will inherit all properties, methods & events from the base classes, independent of how the MovieClip was created Note! The new instance will inherit all properties, methods & events from the base classes, independent of how the MovieClip was created

Creating a MovieClip Symbol Manual (create a MovieClip symbol) Manual (create a MovieClip symbol) 1. Insert new symbol 2. Name the symbol (movieClipName_mc) 3. Draw/make the graphics 4. Open/check the library 5. Drag the symbol from library to the stage 6. Name the instance on main stage (movieClipName_mc) Note! If we make changes to a MovieClip symbol in library, every new instance created from that clip will be changed Note! If we make changes to a MovieClip symbol in library, every new instance created from that clip will be changed

Create a MovieClip by code Dynamic (movieClips created by code), in this example we create a new MovieClip instance named my_mc: Dynamic (movieClips created by code), in this example we create a new MovieClip instance named my_mc: var my_mc:MovieClip = new MovieClip(): Tip! Use the movie clip suffix (_mc) Tip! Use the movie clip suffix (_mc) Note! The movie clip will not be shown until we add it to the Display List (more of this later on...) Note! The movie clip will not be shown until we add it to the Display List (more of this later on...)

MovieClip Class methods, properties & events Example of some of the MovieClip class’s public methods, properties and events: Example of some of the MovieClip class’s public methods, properties and events: Methods: Methods: gotoAndPlay(), gotoAndStop(), play(), stop() Properties: Properties: currentFrame(), currentLabel(), totalFrames() Events: Events: mouseUp, mouseDown(), rollOver(), rollOut() Note! There are more methods, properties and events for the MovieClip Object Note! There are more methods, properties and events for the MovieClip Object

Nested MovieClips & Access We can also nest MovieClips inside another to create complex animations that would be difficult to create on a single timeline We can also nest MovieClips inside another to create complex animations that would be difficult to create on a single timeline We can reach properties, variables, functions from a nested movie clip by using “dot-notation” We can reach properties, variables, functions from a nested movie clip by using “dot-notation” Example of reaching the getData()-function in the second_mc: Example of reaching the getData()-function in the second_mc: first_mc.second_mc.getData(); //function in a nested movieclip To access the root we need to cast it as a MovieClip To access the root we need to cast it as a MovieClip MovieClip(root).gotoAndStop(”video”); //main timeline MovieClip(root).gotoAndStop(”video”); //main timeline Parent will take us up one level: Parent will take us up one level: //we have to cast parent as a movieclip MovieClip(this.parent.parent).my_mc.x = 50; //up two levels

MovieClip Coordinates Each MovieClip has a coordinate system in which the origin Each MovieClip has a coordinate system in which the origin (0, 0) is located in the registration point. For the main timeline this is the top left corner Main timeline MovieClip on stage

Properties A collection of properties describes the object A collection of properties describes the object Ex. An apple has properties like color, size and position A MovieClip has properties (Display Properties) that we can access and manipulate A MovieClip has properties (Display Properties) that we can access and manipulate xPos = 200 yPos = 200 Height = 300 Color = red

Display Properties The Display Properties describes the MovieClip Object’s form The Display Properties describes the MovieClip Object’s form The most common Display Properties, and a migration from AS2 to AS3 is shown below: The most common Display Properties, and a migration from AS2 to AS3 is shown below: Note! The Display Properties are inherits from the DisplayObject class Note! The Display Properties are inherits from the DisplayObject class

MovieClip & Properties We can easily manipulate these properties and then change the form and/or position of the MovieClip Object (square_mc) like: We can easily manipulate these properties and then change the form and/or position of the MovieClip Object (square_mc) like: movieClipInstanceName.propertyName = value; square_mc.scaleX = 2; //scale up 200% in x-direction square_mc.x = 650; //move in x-direction to 650 square_mc.rotation = 90; //rotate 90 degrees square_mc.alpha = 0.5; //50% transparency

Events & Properties In this example we use a button with an EventListener and a function for rotating a rectangle-clip like: In this example we use a button with an EventListener and a function for rotating a rectangle-clip like: //add listener to button rotate_btn.addEventListener(MouseEvent.CLICK, rotateRectangle); //function for rotating function rotateRectangle(e:MouseEvent):void{ rectangle_mc.rotation += 5; //increase degrees by 5 every click rectangle_mc.rotation += 5; //increase degrees by 5 every click}

Properties & Input text We can use an Input text field for changing MovieClip properties on a Mouse press We can use an Input text field for changing MovieClip properties on a Mouse press //add listener to button xPos_btn.addEventListener(MouseEvent.MOUSE_DOWN, xMove); //function for moving box in x-direction function xMove(event:MouseEvent):void{ box_mc.x = Number(xPos_txt.text); //cast input text to number }

Drag’n drop With the drag and drop functionality, we can move our MovieClips around by using the mouse With the drag and drop functionality, we can move our MovieClips around by using the mouse //add listener for the mouse, call handler/functions drag_mc.addEventListener(MouseEvent.MOUSE_DOWN, onStartDrag); drag_mc.addEventListener(MouseEvent.MOUSE_UP, onStopDrag); //handler/function for start dragging function onStartDrag(event:MouseEvent){ event.target.startDrag(); //get the event target } //handler/function for stop dragging function onStopDrag(event:MouseEvent){ event.target.stopDrag();}

Swap Depths (setChildIndex) If we got two or more MovieClips, and want to display/place the active clip on top: we can use the setChildIndex() - method If we got two or more MovieClips, and want to display/place the active clip on top: we can use the setChildIndex() - method to actually swap the depths of the clips //get the number of movie clips on stage var maxIndex:Number = numChildren - 1; //add listener for the mouse, call handler/functions blue_mc.addEventListener(MouseEvent.CLICK, sendToTop); yellow_mc.addEventListener(MouseEvent.CLICK, sendToTop); //handler/function that swaps the depths of active movieclip function sendToTop(event:Event):void{ //setchildindex method, cast the event object as movieclip get maxindex setChildIndex(event.currentTarget as MovieClip, maxIndex); }