Variables, Scope, Images, Sound IM 215 - ActionScript.

Slides:



Advertisements
Similar presentations
INTRODUCTION TO ADOBE FLASH CS4
Advertisements

Flash: Controlling Sound Presentation by Mindy McAdams.
NumericStepper Component You can use the numeric stepper anywhere you want a user to select a numeric value. You can use the numeric stepper anywhere you.
© 2010 Delmar, Cengage Learning Chapter 9: Using ActionScript.
Copyright © 2003 Pearson Education, Inc. Chapter 7 – Slide 1 by Michael Kay The Web Wizard’s Guide to Flash.
Introducing ActionScript 3.0 Object-oriented programming language Used to power Flash Player Similar to JavaScript Can be embedded in a Flash project.
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.
Macromedia Flash 5 Intermediate Level Course. Animation Basics Playhead In-Between Frames Keyframe Current Frame Number Framerate Current Time Frames.
1 Flash Actionscript Adding Interactive Actions Variables.
Kapi’olani Community College Art 258 Interface Programming II In-class Presentation Week 5A.
1 Flash Actionscript Actionscript and Objects. 2 Actionscript and Objects ActionScript is what's known as an object-oriented programming language. Object-oriented.
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.
1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language.
SM1205 Interactivity Topic 06: Iteration and Multiple Objects Spring 2010SCM-CityU1.
Chapter 8 – Part I Interactive Multimedia Authoring with Flash: Animation “Computers and Creativity” Richard D. Webster, COSC 109 Instructor Office: 7800.
“But I don't want to be a “programmer!” ActionScript for journalists Presentation by Mindy McAdams Flashjournalism.com.
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.
Introduction to Flash FYS100 Creative Discovery in Digital Art Forms Spring 2007 Burg.
Flash II MIS439 Eva Tao March 19, 2007 Source:
Lehigh University Introduction to Flash MX Sharmeen Mecklai.
My First ACCESSIBLE Flash Movie. Course notes Detailed course notes, a printable copy of my slides, and all the samples shown today can be downloaded.
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.
CT1514.  What is Motion Guide Layer?  Controls the movement of objects in a Motion tween animation  How to create a Motion Guide Layer?  Click on.
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
® 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.
Getting a handle on ActionScript A basic primer for non-programmers.
Creating Buttons – Lesson 71 Creating Buttons Lesson 7.
Adobe Flash CS3 Revealed Chapter 3 - WORKING WITH SYMBOLS AND INTERACTIVITY.
More Tips on Flash CSC361/661 Digital Media Spring 2007 Burg.
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.
Chapter 16 Video. Importing Video Into Flash  Once you import video into Flash, you can control it using behaviors and very basic ActionScript, target.
2006 Adobe Systems Incorporated. All Rights Reserved. 1 INTRODUCTION TO ADOBE FLASH CS3.
Motion Tweening – Lesson 81 Motion Tweening Lesson 8.
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.
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,
© 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.
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.
© 2011 Delmar, Cengage Learning Chapter 11 Adding Sound and Video.
Basic ActionScript and PHP Cis 126. Getting Started set up a basic folder structure so we can keep our files organized. Mirror this structure on your.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
Intro to ActionScript CIS 126 Greg Shorts. What Is ActionScript? ActionScript is the scripting language Flash uses to control its movies and the objects.
CIS 205—Web Design & Development Flash Chapter 3 Working with Symbols and Interactivity.
Macromedia Flash MX Design Professional And Interactivity WORKING WITH SYMBOLS.
 Movieclip symbols are reusable pieces of flash animation  consisting usually of one or more graphic/button symbols  thus they are flash movies within.
 Motion Tween allow us to move a shape on the stage from one place to another.  In order to use motion tween, the shape to be moved must be converted.
Topic 02: Introduction to ActionScript 3.0
var variableName:datatype;
Unit Lessons Work with actions
INTRODUCTION TO ADOBE FLASH CS4
Interface Programming 2 Week 1
Working with Symbols and Interactivity
MovieCLip Instances & ActionScript
Presentation transcript:

Variables, Scope, Images, Sound IM ActionScript

Legal Variable Names may only contain letters, numbers, dollar signs and under-scores must start with a letter or underscore or a dollar sign are case-insensitive suffixes on your variable names allow for easy type identification when reading var firstName_str; var products_array;

Code hints _mcMovieClip _array Array _str String _btn Button _txt Text Field _sound Sound _color Color _video Video Typical variable suffixes by type:

= vs. == operator if (speed = 100) { //changes the value of speed if (speed == 100) { //does a comparison = sets a value == compares a value This is a common error. If your if/while statements aren’t working, check this first.

Variable Typing Strict vs. Automatic Most programming languages require that variables have explicit data types. Actionscript allows for automatic typing: var firstName; firstName = “Jim”; firstName = “Daisy”; trace (firstName); Convenient, but use explicit typing instead in AS3, e.g.: var firstName:String;

Global vs Local Variables that can be accessed throughout the program are called global variables. Variables that are accessible only to limited sections of the program are called local variables. In Flash, all variables must be scoped to one of the following; A function (local timeline) The main timeline or movie clip ( root variable)

Variables on different timelines Create two different shapes (square, circle) on two different layers. Create an Actions Layer, too. On frame 1 of the square layer set someX to 3 var someX:Number; someX = 3; On frame 1 of the circle layer, set someY to 4 var someY:Number; someY = 4; Place instances of the clips on frame 1 layer 1 of the main timeline and name the instances square and circle On frame 1 of the Actions layer enter the following frame script trace (someX); trace (someY); Test the movie, what happens? (NaN => Not A Number)

Scope Crash! Variables attached to a movie clip timeline have scope limited to that timeline. They are not directly accessible to scripts on other timelines, such as our main movie timeline. What if we place the trace statements on frame 1 of the square layer? Now what happens when you put the trace statements in the circle layer?

Scope in Functions Try this in Actions: var num1:int = 30; var num2:int = 40; var num3:int = 50; addIt(); function addIt():void { var sum:int = num1 + num2 + num3; trace(“Sum from inside the function”); } What happens when you trace the sum after the addIt() function call?

Images Create an empty MovieClip: Insert -> New Symbol Give it the name “spotForPicture” The symbol location on your stage is where the upper left of your image will appear Name the movieclip on the stage currentPicture Add the following AS code: var pic:Loader = new Loader(); pic.load(new URLRequest(“filename.jpg”)); currentPicture.addChild(pic); Use the same code to load a new image—just don’t reinitialize the pic variable.

Sound Objects To create the sound and start it var my_introsound:Sound = new Sound(); my_introsound.load(new URLRequest("sounds/filename.mp3")); var channel:SoundChannel; channel = my_introsound.play(); To stop the sound channel.stop(); See pp in your book

Exercise Create a program that has one frame and four different buttons, Show Image 1, Show Image 2, Play Sound 1, Play sound 2. Do not play a sound or show an image initially. When the user selects a play sound button, a unique sound will play for each button. When the user selects a show image button, a unique image will be displayed for each button.

Sources: “ActionScript 3.0 with Flash CS3 and Flex” (Chapters 3 and 8) by Webster, Yard, and McSharry “Essential ActionScript 3.0” by Colin Moock (O’Reilly)