var variableName:datatype;

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

1What is the Stage. 2How do you open a panel in Flash
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Chapter 14 Sound. Sound  Sound can be used for narration, background soundtracks, rollover noises, and for sound effects to complement animations. 
© 2010 Delmar, Cengage Learning Chapter 9: Using ActionScript.
Adding Interactivity to Flash Movies Using Buttons and ActionScript SPACE Lab
Work with symbols and instances Work with Libraries Create buttons Assign actions to buttons Unit Lessons.
1 Flash Actionscript Adding Interactive Actions Variables.
JavaScript, Fourth Edition
1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language.
Roentgen photo effect. This detailed, thoroughly explained lesson will show you how to create very attractive roentgen photo effect. You can use this.
© 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.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
Tutorial 14 Working with Forms and Regular Expressions.
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
Exercise : Animated Navigation Structure in Flash 1.Develop Answers to “What did you learn in ITI program?” “What do you have to offer?” “What are your.
© 2011 Delmar, Cengage Learning Chapter 9 Introduction to ActionScript 3.0.
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.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
© 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.
CSC 361/661 Digital Media Spring 2010 Professor Burg.
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.
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.
Motion Tweening – Lesson 81 Motion Tweening Lesson 8.
ActionScript: Addressing Display Objects, Duplicating MovieClips, Attaching MovieClips Dynamically MMP 220 Multimedia Programming This material was prepared.
XP Tutorial 8 Adding Interactivity with ActionScript.
Building the Events Components– Lesson 111 Building the Events Components Lesson 11.
Macromedia Flash 8 Revealed WORKING WITH SYMBOLS AND INTERACTIVITY.
1 Actionscript for Flash by Dr SC Li. 2 Understanding more about instances Symbolsgraphics buttons Movie clips Instances (without names) No interaction.
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.
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.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
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 8 Adding Interactivity with ActionScript.
Variables & datatypes Flash ActionScript Introduction to.
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.
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.
 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.
Tarik Booker CS 120 California State University, Los Angeles.
Packages that we use Within ICT we primarily use Dreamweaver CS3 and Flash CS3 This is embedded in an Adobe Design Premium CS3 package (Go to Start >
Topic 02: Introduction to ActionScript 3.0
Session 2 Basics of PHP.
VBA - Excel VBA is Visual Basic for Applications
Adding Buttons, Actions, and Sounds
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Unit Lessons Work with actions
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Variables and Arithmetic Operations
Instructor: Raul Cruz-Cano
WEB PROGRAMMING JavaScript.
Animate Some more advanced concepts
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Chapter Lessons Create shape-tweened animations Create a mask effect
T. Jumana Abu Shmais – AOU - Riyadh
Working with Symbols and Interactivity
MovieCLip Instances & ActionScript
Flash Demonstration – Unit 5 – ActionScript 3.0
Exercise : Animated Navigation Structure in Animate (= Flash)
Exercise : Animated Navigation Structure in Flash
Presentation transcript:

var variableName:datatype; Variables in flash In order to retrieve all the informationm we need to store it into variables. The primary information storage of Actionscript. You can declare variables on a frame in the timeline or directly on an object. Define variables using the var keyword. The general form to declare variables in flash: var variableName:datatype;

Variables in flash variableName: any valid Identifier. Ex) id, myVariable, x 3myVariable is invalid because it starts with a number. Datatype: primitive data types (Number, String, Boolean). There are other built-in data types in flash (such as Sound, Date, …)

Primitive Data Types Number Data Type: It is used to store numeric data types. Numeric types could be integers (4,5,20) or floating-point numbers (2.4,4.321) Ex) example on declaring numeric variable: var f1:Number; Ex) example on declaring a variable with initialization: var f1:Number = 5;

Primitive Data Types Ex) the following example shows how to deal with number variables: Create a new flash file Add a button symbol into the stage. Add text field into the stage Use the text field property inspector to change the text type to (Dynamic Text). And, use it to give the inserted text field an instance name (myText). Instance name is used to access the object using Action script Text Type: Dynamic Text (can be changed during running)

Primitive Data Types In the action panel of the first frame, declare a variable (x) of type Number and initialize it to 4. In the action panel of the button, write the following action script: On (press) { myText.text = x*x + 2*x +4; } Test the movie

Primitive Data Types Boolean Data Type: It is used in logical operations to represent a certain state. It could only hold two values: true false Ex) var f2:Boolean = true;

Primitive Data Types String Data Type: It used to store data as a text ( a sequence of characters). Ex) “This is some text” String in flash should be enclosed within double quotation (“”) Ex) to declare a variable (s) of type String and store “some text” in it: var s:String = “some text”;

Primitive Data Types Each character in a string has an index. The indices of characters are numbered (0,1,2,3,…) from left to right. The string characters created in the previous example have indices as follows: s o m e t e x t 0 1 2 3 4 5 6 7 8

Primitive Data Types Functions to manipulate string: charAt(i); This function returns a character from a string found in index (i) i: integer number represent an index. Ex) var s:String = “some text”; trace(s.charAt(2)); // m indexOf(str); This function returns the index of the passed (str) within the text. Ex) trace(s.indexOf(“m”)); // 2

Primitive Data Types length; substr(index,length); Returns the number of characters in the string. Ex) trace(s.length); // 9 substr(index,length); Returns a part of the string as specified in the parameters. index: an integer gives the starting point of the taken part. length: the number of characters to take starting at (index). Ex) trace(s.substr(1,5)); // ome t s o m e t e x t 0 1 2 3 4 5 6 7 8 index

Primitive Data Types toUpperCase(); toLowerCase(); Returns the capital letter representation of the string. toLowerCase(); Returns the lower letter representation of the string.

String Example Ex) this example illustrate how to build a flash program to read string value from keyboard, convert it to its capital representation, and print the result in a text field on the stage: Create a flash file. Insert a text field on the stage, convert its type to (Input Text) and give it an instance name (txtinput) When you change the type of a text field to (Input Text), you can insert text values into it at runtime from keyboard. Giving an instance name to a text fields allow us to access it using action script.

String Example Insert a text field on the stage. Convert its type to dynamic and give it an instance name (txtoutput) Add a button on the stage. Insert the text (Convert to Capital) in the button. In the action pane of the button, add the following script: on(press) { var s:String; s = txtinput.text; txtoutput.text = s.toUpperCase(); } To take the text inserted into (txtinput) and assign it to (s) To make return the capital letter representation of s. Then assign it to (txtoutput)

Global variable Global variables are visible to every timeline and every scene in your flash file. To declare (or create) a variable with global scope, use the _global identifier before the variable name and do not use the var keyword. Ex) _global.myName = “globalvar";

Flash Sounds There are two ways to add sounds to our flash file: import a sound file (in whatever format the flash editor can handle, e.g. mp3, wav... etc), and pull it onto the stage. Ex) create new flash file Go to FileImportImport to Library Choose the sound file from your computer, and click open. You can notice that your sound file was added to your library. Now, Drag and drop that flash symbol into the stage. Test the movie

Flash Sounds if you want to have better control in playing the sound file, you may need some actionscripts. starting and stopping the music by pressing the corresponding button. Ex) This example illustrates how to control sounds inside flash program. Open a new file in the Flash Import a sound file into the library. MRC on the imported sound(in the library window; you may need to open the library window first), and select linkage on the pop up menu.

Flash Sounds check the export to actionscript option and type the name "mysound" in the textbox. This will assign an id to the imported sound, so later on the actionscripts can refer to it. Ok, back to the main stage. Select the first frame on the timeline, open the action window and put the following code in it: var snd:Sound = new Sound(); snd.attachSound("mysound"); Basically, the above code will create a sound object and attach the imported sound file to it. insert a (play) button in the stage and write the following code in the action pane of it:

Flash Sounds on(release) { _root.snd.start(0, 10); } Action is performed when releasing the button _root: to access every object in the main timeline Start(0,10): This will start playing the sound (and loops 10 times) when the button is clicked.

Flash Sounds Repeat step 6 to create the stop button but associated with the following actionscritps instead: on(release) { _root.snd.stop(); } Stop(): to stop the sound