ActionScript: Loading External Content with MovieClipLoader Class, Listener Objects, Preloaders, HitTest, Loading Sound MMP 220 Multimedia Programming.

Slides:



Advertisements
Similar presentations
INTRODUCTION TO ADOBE FLASH CS4
Advertisements

Tutorial 7 Planning and Creating a Flash Web Site.
Class-level Methods and Inheritance MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
Chapter 6 Preparing and Publishing Applications. Chapter 6 Lessons 1.Publish movies 2.Reduce file size to optimize a movie 3.Create a preloader 4.Publish.
“Computers and Creativity”
© 2010 Delmar, Cengage Learning Chapter 9: Using ActionScript.
The Web Warrior Guide to Web Design Technologies
Introducing ActionScript 3.0 Object-oriented programming language Used to power Flash Player Similar to JavaScript Can be embedded in a Flash project.
INTEGRATING Macromedia MX 2004 Products Integrating Macromedia MX 2004.
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.
1 Flash Actionscript Adding Interactive Actions Variables.
Macromedia Flash 5 Advanced Level Course. Using Actions Toolbox ListActions List Parameters area Add/Delete a StatementMove Action Up/Down Expand/Collapse.
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 and Animation Presented by : Behzad Sajed Khosrowshahi.
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.
© 2010 Delmar, Cengage Learning Chapter 6: Preparing and Publishing Movies.
6-1 OBJ Copyright 2003, Paradigm Publishing Inc. Animating Using Symbols and Masks and Publishing Flash Movies Macromedia Flash Design & Application.
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 4 Dreamweaver: Part II The Web Warrior Guide to Web Design Technologies.
Chapter 15 Video. Importing Video Into Flash Once you import video into Flash MX 2004, you can control it using behaviors and very basic ActionScript,
BUILDING RICH MEDIA ELEMENTS. Design Decisions Based on Design Specification  Following the design specification will ensure that the application is.
The Document Object Model. Goals Understand how a JavaScript can communicate with the web page in which it “lives.” Understand how to use dot notation.
THE BIG PICTURE. How does JavaScript interact with the browser?
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.
® Copyright 2008 Adobe Systems Incorporated. All rights reserved. ® ® 1 INTRODUCTION TO ADOBE FLASH CS3.
® Copyright 2010 Adobe Systems Incorporated. All rights reserved. ® ® 1 INTRODUCTION TO ADOBE FLASH PROFESSIONAL CS5.
Creating a Logo – Lesson 3 1 Creating a Logo Lesson 3.
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.
Tutorial 7 Planning and Creating a Flash Web Site.
More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg.
CSC 361/661 Digital Media Spring 2010 Professor Burg.
Introduction to Flash Animation CS 318. Topics Introduction to Flash and animation The Flash development environment Creating Flash animations  Layers.
ActionScript: Addressing Display Objects, Duplicating MovieClips, Attaching MovieClips Dynamically MMP 220 Multimedia Programming This material was prepared.
ActionScript: Functions, Parameters, Functions that return a value, Variables, setInterval Functions MMP 220 Multimedia Programming This material was prepared.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.
© Anselm Spoerri Lecture 10 – Related: Part 1 Flash –Build Flash Website with Animated Navigation Structure –Decide on Overall Navigation Layout, Import.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
XP Tutorial 8 Adding Interactivity with ActionScript.
Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now.
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.
© 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.
Classes, Objects, and World-level Methods MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
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.
Programming: Simple Control Structures MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum.
SCRIPT PROGRAMMING WITH FLASH Introductory Level 1.
Video in Macromedia Flash (Optional) – Lesson 121 Video in Macromedia Flash (Optional) Lesson 12.
Review of Previous Class Declaring variables var myVariableName:DataType = variableValue;
© 2011 Delmar, Cengage Learning Chapter 11 Adding Sound and Video.
Interactive Programming MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum redesign project.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Parameters MMP 220 Multimedia Programming This adapted material was prepared for students in MMP220 as as part of a curriculum redesign project funded.
XP Tutorial 8 Adding Interactivity with ActionScript.
CISC 110 Day 7 “The Outliers, Part1” hitTest(), Text Input, Frame and Timer Loops, Publishing Flash Content.
Mike Mulhearn & Drew Hobbs IMAGE ICON.  Paints icons from images  Images can be JPEG, JPG, GIF, PNG, BMP, WBMP  Images may also be created from a URL,
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
Internet & World Wide Web How to Program, 5/e.  JavaScript events  allow scripts to respond to user interactions and modify the page accordingly  Events.
CDM105 Session 12 Macromedia FLASH MX 2004 Part 5 : Sounds, publishing your movies, and the ‘Get URL’ action.
Flash Demonstration – Unit 3 Create Multi-Part Animation –Animate Images –Fade-in and Fade-out Text –Add Interactivity to Instance of MovieClip –Animated.
Creating a Flash Web Site
Using Video, and Flash Components, and Printing Flash Content
Unit Lessons Work with actions
INTRODUCTION TO ADOBE FLASH CS4
Flash & ActionScript Syntax is similar to JavaScript
Animation Programs: Scenarios and Storyboards
Presentation transcript:

ActionScript: Loading External Content with MovieClipLoader Class, Listener Objects, Preloaders, HitTest, Loading Sound 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

Benefits of Dynamically Loading Content Your want to break your project down into parts that will download rapidly, rather than have the user download one enormous file Much of your content is dynamically generated Some parts of the application need to be updated frequently Your application has several different authors or teams who are developing some part of the content

Loading swf files: When you load swf content using the MovieClipLoader class, the content replaces the timeline content of the containing clip, which is why it is a good idea to create an empty movieclip to contain your content. The content retains the _x, _y, _alpha, _xscale and _yscale properties.

Syntax for loading swf //first create an empty clip to hold content this.createEmptyMovieClip("circleSWFHolder_mc",getNextHighestDepth()); //create a MovieClipLoader object var swfLoader_mcl:MovieClipLoader = new MovieClipLoader(); //use loadClip() method of the MovieClipLoader object, parameter is //url where clip is stored swfLoader_mcl.loadClip(" circleSWFHolder_mc);

Loading Images You can load image files (jpeg, png, gif) into you Flash movies using the MovieClipLoader object. When you load an image into a clip, it replaces the timeline content of the clip. This means that the object can no longer be treated fully as a clip- the methods of the movieClip class will not work on an image file. So if, for example, you want to load an image and make it draggable, you must load the image content into a clip that is within a clip.

Syntax for nesting clip into clip to load image content this.createEmptyMovieClip("imageHolder_mc",this.getNextHighest Depth()); imageHolder_mc.createEmptyMovieClip("image_mc", imageHolder_mc.getNextHighestDepth()); var imageLoader:MovieClipLoader = new MovieClipLoader(); imageLoader.loadClip("batman.jpg", imageHolder_mc.image_mc);

MovieClipLoader Class, and Listener Objects MovieClipLoader objects work with listener objects, which monitor the progress of loading content. A listener object for a MovieClipLoader instance is just an object that has methods of the MovieClipLoader class defined.

Methods Defined onLoadStart() - invoked when content begins to load- passed a reference to MovieClip object into which content will be loaded. onLoadProgress() – invoked continually while data is loaded. 3 parameters are passed- name of MovieClip into which data will be loaded, number of loaded bytes, number of total bytes. onLoadInit() - invoked when data has loaded and is initialized. onLoadComplete() – invoked when content has completely loaded. Parameter passed is reference to MovieClip object into which content was loaded.

Example var myListener:Object = new Object(); myListener.onLoadStart = function(holderClip_mc:MovieClip):Void{ trace(holderClip_mc +” started loading”); }; myListener.onLoadProgress= function(holderClip_mc:MovieClip, nloaded:Number, nTotal:Number):Void{ trace(holderClip_mc + nloaded + “ of “ + nTotal + “ bytes”); }; myListener.onLoadInit=function(holderClip_mc:MovieClip):Void{ trace(holderClip_mc + “ initialized”); }; myListener.onLoadComplete = function(holderClip:MovieClip):Void{ trace(holderClip_mc + “ completed loading.”) This creates a listener object, and traces information about download progress of a clip into the output window.

To use a MovieClipLoader listener: Create a movieClip object to load content into this.createEmptyMovieClip(“holder_mc”, this.getNextHighest Depth()); Next create a MovieClipLoader object var loader_mcl:MovieClipLoader= new MovieClipLoader(); Create a listener object var myListener:Object = new Object(); Use addListener() method to add the listener object ot the MovieClipLoader instance loader_mcl.addListener(myListener); Invoke loadClip() method from MovieClipLoader object

Preloaders Preloaders use the methods of the MovieClipLoader Class to monitor progress of the download and convert the information into something the user can view, such as a bar whose length increases proportionally as the clip loads, or as numbers that identify the percentage of the clip that has loaded.

Unloading Content You can unload content from a clip by either: Loading new content into the clip Using the unloadClip() method of the MovieClipLoader Class. This requires one parameter, a reference to the movieClip that was loaded with a MovieClipLoader.

hitTest() A method that checks for overlap- you can use to see if 2 clips have overlapped. This example checks to see if circle_mc is overlapping square_mc and stores the result of the check in a Boolean variable overlap var overlap:Boolean= circle_mc.hitTest(square_mc);

hitTest() example 2 Another way to use hitTest() is to pass it 3 parameters, and X coordinate, a Y coordinate, and a Boolean value that indicates whether you want to test on the actual shape of the object, or the bounding box of the object. Example: var overlap:Boolean = circle_mc.hitTest(this._xmouse, this._ymouse, true); This checks to see if the mouse is currently over the object circle_mc.

Assignment Read pages 277 – 285 in Chapter 14 of the ActionScript Bible.