ActionScript: Addressing Display Objects, Duplicating MovieClips, Attaching MovieClips Dynamically MMP 220 Multimedia Programming This material was prepared.

Slides:



Advertisements
Similar presentations
Tutorial 7 Planning and Creating a Flash Web Site.
Advertisements

© 2010 Delmar, Cengage Learning Chapter 9: Using ActionScript.
 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.
1 Flash Actionscript Event Handling. 2 Event Handling Right now we know all about variables lets go back to our text input/output example: Suppose we.
Flash Workshop Flash Workshop :: Agenda  Introductions  Look at a few Flash Examples  Flash Web Sites  Flash Web Applications  Flash Games.
Work with symbols and instances Work with Libraries Create buttons Assign actions to buttons Unit Lessons.
1 Flash Actionscript Adding Interactive Actions Variables.
Kapi’olani Community College Art 258 Interface Programming II In-class Presentation Week 5A.
1 Flash Actionscript Adding Interactive Actions. 2 ActionScript 3.0 ActionScript is the language you use to add interactivity to Flash applications, whether.
1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language.
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.
MovieClips & Properties Flash ActionScript Introduction to Thomas Lövgren
© 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.
Chapter 3 Working with Symbols and Interactivity.
Chapter 4 Dreamweaver: Part II The Web Warrior Guide to Web Design Technologies.
BUILDING RICH MEDIA ELEMENTS. Design Decisions Based on Design Specification  Following the design specification will ensure that the application is.
Chapter 11 Adding Sound and Video. Chapter 11 Lessons 1.Work with sound 2.Specify synchronization options 3.Modify sounds 4.Use ActionScript with sound.
© 2011 Delmar, Cengage Learning Chapter 9 Introduction to ActionScript 3.0.
Publishing a Macromedia Flash Movie – Lesson 131 Publishing a Macromedia Flash Movie Lesson 13.
Adobe Flash CS5.5. What is Adobe Flash? formerly Macromedia Flash Is software is a powerful authoring environment for creating animation and multimedia.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
Creating a Logo – Lesson 3 1 Creating a Logo Lesson 3.
© 2010 Delmar, Cengage Learning Chapter 3: Working with Symbols and Interactivity.
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
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.
Our Examples Video Capture Working With Interactive Video Objects Buttons symbols – are areas on the monitor that a sensitive to user actions such.
XP Tutorial 4 Special Animations. XP New Perspectives on Macromedia Flash MX Special Layers for Animation Animation Using a Motion Guide Layer.
Tutorial 7 Planning and Creating a Flash Web Site.
Creating Buttons – Lesson 71 Creating Buttons Lesson 7.
Adobe Flash CS3 Revealed Chapter 3 - WORKING WITH SYMBOLS AND INTERACTIVITY.
Motion Tweening – Lesson 81 Motion Tweening Lesson 8.
ActionScript: Loading External Content with MovieClipLoader Class, Listener Objects, Preloaders, HitTest, Loading Sound MMP 220 Multimedia Programming.
ActionScript: Functions, Parameters, Functions that return a value, Variables, setInterval Functions MMP 220 Multimedia Programming This material was prepared.
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.
XP Tutorial 8 Adding Interactivity with ActionScript.
Variables, Scope, Images, Sound IM ActionScript.
Building the Events Components– Lesson 111 Building the Events Components Lesson 11.
Macromedia Flash 8 Revealed WORKING WITH SYMBOLS AND INTERACTIVITY.
ActionScript: For Loops, While Loops, Concatenation and Arrays MMP 220 Multimedia Programming This material was prepared for students in MMP220 Multimedia.
ActionScript: Classes, Properties, EventHandler Methods, Datatypes & Control Structures MMP 220 Multimedia Programming This material was prepared for students.
XP Tutorial 7 Creating a Flash Web Site. XP New Perspectives on Macromedia Flash 82 Objectives Plan and create a Flash Web site Create a Flash template.
Adding Text and Navigation to the Home Page – Lesson 51 Adding Text and Navigation to the Home Page Lesson 5.
Flash ActionScript Introduction to Scope & Levels duplicateMovieClip & attachMovieClip.
Tutorial 3 Creating Animations. XP Objectives Learn the different elements of animation Create frames and layers Organize frames and layers using the.
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.
© 2011 Delmar, Cengage Learning Chapter 11 Adding Sound and Video.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
XP Tutorial 3 Creating Animations. XP New Perspectives on Macromedia Flash MX Elements of Animation Layers are used to organize the content of.
XP Tutorial 8 Adding Interactivity with ActionScript.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
 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.
var variableName:datatype;
Creating a Flash Web Site
Using Video, and Flash Components, and Printing Flash Content
Creating Complex Animations
Tutorial 6 Creating Dynamic Pages
Interface Programming 2 Week 1
Working with Symbols and Interactivity
Flash Concepts and Demos - Overview
Flash Demonstration – Unit 5 – ActionScript 3.0
Exercise : Animated Navigation Structure in Animate (= Flash)
Presentation transcript:

ActionScript: Addressing Display Objects, Duplicating MovieClips, Attaching MovieClips Dynamically MMP 220 Multimedia Programming This material was prepared for students in MMP220 Multimedia Programming as as part of a curriculum redesign project funded by National Science Foundation grant # Co PI’s Christopher Stein and Jody Culkin BMCC CUNY

Display Objects The term display object refers to classes that have a visible representation on the stage. The four classes that we refer to as display objects are MovieClip, Button, TextField and Video. Some display objects can only be created at authoring time, others can be created at runtime as well as at authoring time.

Addressing Display Objects As we have seen, the simplest way of addressing a display object would be when it is on the main timeline and we use the dot syntax. movieClipInstanceName.methodOrProperty Example: circle_mc.play();

Targeting Nested Instances Sometimes you are referring to a movieClip that is nested inside of another clip or timeline. This is called targeting nested instances. Here is the syntax: parentMovieClip.nestedInstance.methodOrProperty Example: cloud_mc.rain_mc.play();

Targeting Instances Your targeting can be several clips deep, as in this example: store_mc.shelf_mc.shoe_mc._x+=5; This example moves the clip shoe_mc that is in the timeline of the shelf_mc clip that is in the timeline of the store_mc clip.

Absolute Addressing All flash movies have a main MovieClip object- it is considered the root of all the content in the movie. This means that all the other MovieClip objects in the movie are considered properties of this main MovieClip object. There is a specific name (identifier) that can be used to reference it- _root.

Absolute Addressing Absolute addressing (_root.circle_mc.square_mc.my_sound) should be avoided, since the nature of flash is to load one clip or timeline into another- and thus what is considered _root is always subject to change.

Relative Addressing Relative addressing is, just as the name implies, always relative to the timeline from which the code has been issued. You can refer to both the parent elements, and the child elements with relative addressing. The keyword this refers to the current movieClip or movieClip timeline on which the current code is running.

Referencing Child Elements To reference child elements, use the following syntax: car_mc.onPress=function():Void{ this.wheel_mc.play(); } wheel_mc is a clip on the timeline of car_mc

Referencing Parent Elements To reference the parent of a clip, use this syntax: circle_mc.onRelease = function():Void{ this._parent.play(): } This references the movieClip that the clip circle_mc is on.

Accessing Nested Instances with Array-Access Notation As we saw last week, you can use array access notation to address objects. for(var I:Number; I<=4; i++){ circle(“square” + i).play(): }

Stacking Order within Flash Movies We are used to working with layers in flash in the authoring environment to indicate the order of the Z axis- or which objects are “on top” of others. When our Flash document is exported, layers are discarded, but the objects’ placement levels are converted to depths. Each object has its own unique depth. When we are creating display objects on the fly, we need to assign each object a unique depth.

getNextHighestDepth() In order to insure that we are not putting more than one object at a particular depth, we can use getNextHighestDepth() method, which returns the next highest depth of the MovieClip from which the method is called.

Ways of Dynamically Loading Clips on the Stage There are a number of different ways to dynamically load MovieClips on the stage with ActionScript: duplicateMovieClip() attachMovie () createEmptyMovieClip()

Duplicate MovieClip Instances This method creates a duplicate of a movieClip instance that is currently on the stage. Syntax: circle_mc.duplicateMovieClip(“newCircle_mc”,this.getNextHighestDepth()); Parameters are a new instance name and a depth for the clip. The instance circle_mc is duplicated and the new instance name is newCircle-mc.

Adding MovieClip Objects from the Library Programmatically In order to do this, you must first set up a unique linkage identifier for the symbol in the symbol properties dialog box. 1.Click the symbol in the library. 2.Right click and select the Linkage option. 3.In the Linkage Properties dialog box, select Export for ActionScript, and Export in the first frame. 4.Click ok.

AttachMovie attachMovie creates a new instance of a movieClip in the library. Syntax: holder_mc.attachMovie(“circle”, “circle_mc”, getNextHighestDepth()); Parameters are the linkage identifier, a new name for the instance, a depth for the clip. In the example above, a clip with id circle with the instance name circle_mc is attached to a clip named holder_mc at a depth that is one step higher than the highest depth in holder_mc.

Initialization Objects When you use the attachMovie method, or duplicateMovieClip you have the option of using an initialization object to set the horizontal and vertical position of the clip. This init object is passed along with the parameters, inside of curly braces, with the following syntax: (it would be on one line in the script pane.) holder_mc.attachMovie(“square”, “square_mc”, getNextHighestDepth(),{-x:50:, _y:100});

Creating Empty MovieClip Objects Sometimes you want to create an empty movieClip- it is particularly useful for:  Attaching several movieclips instances with one empty movieclip to move, resize or otherwise control these clips.  To load external content, such as image or swf files.

createEmptyMovieClip Syntax this.createEmptyMovieClip(“swfHolder_mc”, this.getNextHighestDepth()); The parameters are the instance name, and the depth for the clip. Unlike duplicateMovieClip and attachMovie, no initialization object can be passed with createEmptyMovieClip. The clip is loaded into 0,0 (or upper left corner) of the parent element’s coordinate system.

Removing MovieClip Objects The removeMovieClip() method will remove a object form the stage. Syntax: circle_mc.removeMovieClip(); This code will remove the clip circle_mc from the stage.

Assignment Read pages in Chapter 13 and pages 269 – 277 in Chapter 14 of the ActionScript Bible.