180 likes | 426 Views
Introduction to Scripting Language. Introducing ActionScript 3.0. Object-oriented programming language Used to power Flash Player Similar to JavaScript Can be embedded in a Flash project (.fla) file
E N D
Introducing ActionScript 3.0 • Object-oriented programming language • Used to power Flash Player • Similar to JavaScript • Can be embedded in a Flash project (.fla) file • Written as a stand-alone ActionScript (.as) file, or created in Flex Builder (new tool built on Adobe’s Flex framework – creating RIAs (Rich Internet Applications)
ActionScript help a Flash designer to leap the hurdle and create fully interactive applications, dynamic Web applications and interactive video games • History of ActionScript • ActionScript 1.0 • ActionScript 2.0 • ActionScript 3.0
ActionScript 1.0/2.0 vs 3.0 myMovieClip.createTextField(“thickness_text”, 10, 0, 0, Stage .width, 22); var myText:TextField = new TextField(); ActionScript 1.0/2.0 Class Method Instance Name Properties ActionScript 3.0 Instance Name Class Method
Benefits of ActionScript 3.0 • fast downloading speed • precise visual control • advanced interactivity • capable to combine bitmap and vector gaphics • include video and animation • scalable and streaming content SMM3111 - Multimedia Programming
ActionScript 3.0 elements, including the following: • Variables • Instances and Instances Name • Properties • Functions and methods • Event, event handlers, and event listeners • Classes • Conditional statements SMM3111 - Multimedia Programming
Communicating to Movie Clips • Firstly, transform the object into a movie clip symbol (a type of predefined class). • Give an instance name which ActionScript can interact with it. • A guidelines when naming symbols, instance and document files in Flash: • Use lowercase letters (a-z) for the first character • Use descriptive names to make it easy to remember • Do not use special character (!, @, #, $, % and many others) • Never use spaces • Never put periods (.) • Never put slashes (/) Example: mcRectangle; rectangle_mc; etc SMM3111 - Multimedia Programming
Modifying movie clip properties • Giving a script to movie clips: • select a particular frame on a particular layer • choose Window > Actions or press F9 to open the Actions panel SMM3111 - Multimedia Programming
Actions panel has three basic areas • Script pane – where you type the ActionScript • Actions toolbox – contains a listing of all the classes, methods, events and parameters • Script navigator – use to navigate to the different frames containing ActionScript
Example: rectangle1_mc.alpha = .5; Meaning: • telling Flash that the object’s (instance name = rectangle1_mc) is given alpha property or transparency that equal to .5 or 50 percent. • semicolon shows the end of statement SMM3111 - Multimedia Programming
Understanding variables and setting variable data type • Variable – a container that holds information or different data • syntax in ActionScript: var <variable_name> eg.: var userName • Giving a value to the variable. The value or data type will be string and numbers. eg.: var userName:String = “Todd”; SMM3111 - Multimedia Programming
Trace Statements • To make sure the code is syntaxed and running properly • Syntax in ActionScript: trace <variable_name>/<(string)> SMM3111 - Multimedia Programming
A trace statement pops up in the Output panel when we test or publish the movie. • Output panel has no information or a coded error message. • It helps you check the code and isolate any problems when you start to work with complicated files.
Comments • Comments are notes – usually to yourself or to other coders looking at the file. • Used to explain coding decisions, such as • the file organization, or • annotate the code, or • sometimes, temporarily turn off a block of code • Two type of comments: • // - line comments • /* - block comments SMM3111 - Multimedia Programming
Syntax in ActionScript: // <your comments> or /* <more than one line of comments> */ eg.: SMM3111 - Multimedia Programming