“But I don't want to be a “programmer!” ActionScript for journalists Presentation by Mindy McAdams Flashjournalism.com.

Slides:



Advertisements
Similar presentations
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Advertisements

Flash: Controlling Sound Presentation by Mindy McAdams.
Introduction to Computing Science and Programming I
Flash Week 5 Presentation by Mindy McAdams. Post-mortem: Flash 3 exercise Sliding panel functionality Use of big, beautiful pictures (vs. tiny pictures)
Conditional Statements and Loops. Today’s Learning Goals … Learn about conditional statements and their structure Learn about loops and their structure.
1 Loops. 2 Often we want to execute a block of code multiple times. Something is always different each time through the block. Typically a variable is.
Executes a statement or statements for a number of times – iteration. Syntax for(initialize; test; increment) { // statements to be executed } Initial.
Scratch Programming Session 9 of 10 Review elements to use in stories, games, etc.
Flash Workshop Flash Workshop :: Agenda  Introductions  Look at a few Flash Examples  Flash Web Sites  Flash Web Applications  Flash Games.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
1 Flash Actionscript Adding Interactive Actions Variables.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
CS 106 Introduction to Computer Science I 09 / 28 / 2007 Instructor: Michael Eckmann.
Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
© 2011 Delmar, Cengage Learning Chapter 8 Building Complex Animations.
While Loops and Do Loops. Suppose you wanted to repeat the same code over and over again? System.out.println(“text”); System.out.println(“text”); System.out.println(“text”);
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Using Data Active Server Pages Objectives In this chapter, you will: Learn about variables and constants Explore application and session variables Learn.
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
Advanced Web 2012 Lecture 4 Sean Costain PHP Sean Costain 2012 What is PHP? PHP is a widely-used general-purpose scripting language that is especially.
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #005 (April somthin, 2015)
Making a Timer in Alice.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Classes and Objects. Topics The Class Definition Declaring Instance Member Variables Writing Instance Member Methods Creating Objects Sending Messages.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Media in PowerPoint Learning Goal: Today you are going to explore how music and video can be added to a presentation.
 Make sure you are subscribed to announcements on Moodle.  Activity 4 will be due 48hrs after your lab ends.
EET 2259 Unit 7 Case Structures; Sequence Structures  Read Bishop, Sections 5.4 and 5.5.  Lab #7 and Homework #7 due next week.  Quiz #3 next week.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Programming games Flash drawing trick(s). Past due: Your completion of rock-paper-scissors) Classwork: Bouncing ball: read tutorial. Start coding.
Using Shortcut Arithmetic Operators Accumulator: A variable that is used to total. Its value is repeatedly increased by some amount. Java provides shortcuts.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (there is an audio component to this eLesson) © Dr.
ALBERT WAVERING BOBBY SENG. Week 4: JavaScript  Quiz  Announcements/questions.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements I.
DH2T 34 – HNC Computer Architecture 1 Lecture 14 The Fetch-Decode-Execute Cycle [1]. © C Nyssen/Aberdeen College 2003 All images © C Nyssen/Aberdeen College.
Variables, Scope, Images, Sound IM ActionScript.
C++ / G4MICE Course Session 2 Basic C++ types. Control and Looping Functions in C Function/method signatures and scope.
ActionScript: For Loops, While Loops, Concatenation and Arrays MMP 220 Multimedia Programming This material was prepared for students in MMP220 Multimedia.
IS2802 Introduction to Multimedia Applications for Business Lecture 3: JavaScript and Functions Rob Gleasure
CRE Programming Club - Class 2 Robert Eckstein and Robert Heard.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 5: Looping.
Flash: ActionScript review & Controlling Sound Presentation by Mindy McAdams Edited for JOMC 187, UNC-Chapel Hill by Laura Ruel.
Open a new Flash File Action Script 2.0. Create a button like you did last lesson and name it Click to Play.
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.
Arrays-. An array is a way to hold more than one value at a time. It's like a list of items.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
Animations in GIMP GIMP Lesson 4 Animations: Chapter 3 pp Beginning GIMP From Novice to Professional.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Copyright © 2014 Curt Hill Algorithms From the Mathematical Perspective.
Introduction to TouchDevelop Lesson 3 – Comments & Lists Created by S. Johnson
Debugging No readings. 2 What's The Proper Indentation? function max(x,y) { if (x
While loops. Iteration We’ve seen many places where repetition is necessary in a problem. We’ve been using the for loop for that purpose For loops are.
Arrays and Loops. Learning Objectives By the end of this lecture, you should be able to: – Understand what a loop is – Appreciate the need for loops and.
Chapter Looping 5. The Increment and Decrement Operators 5.1.
Today… Python Keywords. Iteration (or “Loops”!) Winter 2016CISC101 - Prof. McLeod1.
Learning Javascript From Mr Saem
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
 Movieclip symbols are reusable pieces of flash animation  consisting usually of one or more graphic/button symbols  thus they are flash movies within.
JavaScript Controlling the flow of your programs with ‘if’ statements
CHAPTER 4 DECISIONS & LOOPS
JavaScript: Control Statements.
Cookies BIS1523 – Lecture 23.
Coding Concepts (Basics)
Introduction to TouchDevelop
CSCI N207 Data Analysis Using Spreadsheet
A First Program.
CSE 153 Design of Operating Systems Winter 19
Chap 7. Advanced Control Statements in Java
Presentation transcript:

“But I don't want to be a “programmer!” ActionScript for journalists Presentation by Mindy McAdams Flashjournalism.com

Functions in scripting languages  A function is a self-contained script that can be executed on demand, and which does not run until it is told to run  Actions you have already seen — such as stop() and play() — can be contained inside a function

Conventions of a function  In Exercise 8.7, you see a typical function for the first time in this book (“Synchronizing images to loaded audio”)  A typical ActionScript function looks like this: function nameOfFunction() { stuff here; }

Using a function  The function: function nameOfFunction() { stuff here; }  Calling the function (later): nameOfFunction();  When you call a function, whatever script is inside { } will be executed

Choosing a name for a function  The name of a function must not be any of the reserved words in ActionScript (see pp )  This is the reason why you see some strange names for functions, such as loadTheMovie – because you cannot name a function “load,” or “loadMovie”  ActionScript would be “confused” if you used a reserved word to name a function

Similarity to other languages  ActionScript is based on an international standard known as ECMAscript  JavaScript is also based on ECMAscript  ActionScript has many similarities to JavaScript, but they are NOT the same thing!  Don’t assume you can use terms from JavaScript  Look up the ActionScript methods, etc., in the Flash Help files

When to create a function  You realize you will need to do the same thing more than once in the Flash movie  The one function can be called many times  A function can be called on a frame, or on a button

Example of a function  Say you want a function to pause a Sound object (stored in a variable named x)  Write the function (once): function pauseMySound() { p = Math.floor(x.position/1000); x.stop; }  Call the function (many times): pauseMySound();

Define variables outside functions  There are two variables in this function: function pauseMySound() { p = Math.floor(x.position/1000); x.stop; }  You must declare the variables BEFORE the function, and OUTSIDE of the {} var p = 0; var x = new Sound();  Remember: A variable is declared (with var) only ONCE in a movie

Passing a variable to a function  If you want the function to be performed on different variables in different parts of your movie  Write the function (once): function pauseMySound(theSound) { p = Math.floor(theSound.position/1000); theSound.stop; }  Call the function (in this case, only for x): pauseMySound(x);

Passing a variable (2)  If you have something in parens here: function pauseMySound(theSound) { p = Math.floor(theSound.position/1000); theSound.stop; }  You MUST put an existing variable name in the parens when you call the function: pauseMySound(x);

NOT passing a variable  If you have nothing in parens here: function pauseMySound() { p = Math.floor(x.position/1000); x.stop; }  You MUST NOT put anything in the parens when you call the function: pauseMySound();

Things we do with functions  Test a condition (if … then)  Do something again and again until some condition is met Usually with a loop Or with … onEnterFrame Or with … setInterval

Testing a condition  The condition (if) is defined in parens; for example: if (x.getVolume() > 0)  The result (meaning “then do this”) is contained in curly braces: { x.setVolume(0); }  This says: “If the current volume of sound x is greater than zero, then set the volume of x to zero”

Testing a condition (2)  The function: function volumeToZero() { if (x.getVolume() > 0) { x.setVolume(0); }  This says: “If the current volume of sound x is greater than zero, then set the volume of x to zero”

Adding “else” to a condition function changeMyVolume () { if (x.getVolume() > 0) { x.setVolume(0); } else { x.setVolume(100); }  This says: “If the current volume of sound x is greater than zero, then set the volume of x to zero; otherwise, set the volume of x to 100; ”

Running a “for” loop  There are different kinds of loops in scripting; a “for” loop is very common  The beginning of a “for” loop: for (i=0; i<=7; i++) { stuff; }  This means: The initial value of i is zero For as long as i is less than or equal to 7 … Increment i (that is, add 1 to i)  The initial value of i can be anything  The condition can be anything  You can decrement or increment i

Use of onEnterFrame  Explained in the book, pp , and in Exercise 10.5, Step 6  If you use _root.onEnterFrame --  You must eventually stop or cancel it (otherwise, disaster!): delete _root.onEnterFrame;  Never try to use two simultaneous instances of _root.onEnterFrame

Use of setInterval  Explained in the book, Exercise 10.7, Step 9  If you use setInterval --  You must eventually stop or cancel it (otherwise, disaster!)  To stop a setInterval you must first name the interval; this means you CAN run two or more setInterval s at the same time

Naming and clearing setInterval  Say you have created a function named “changePhoto”  To use setInterval with that function: timer = setInterval(changePhoto, 3000);  You have named the interval “timer”  To stop this setInterval -- clearInterval(timer);

What does setInterval do?  Use it to determine how often a function will execute timer = setInterval(changePhoto, 3000);  3000 is 3 seconds  Usually we combine setInterval with a condition, e.g., “If we have shown fewer than 10 photos, then show a new photo after 3 seconds have passed”

The End Presentation by Mindy McAdams Flashjournalism.com