220 likes | 325 Views
IM 215 Intro to Scripting Languages. Objectives. The core objectives of this course are as follows: Students will understand basic foundations of JavaScript, including its usage in the web and application design and development.
E N D
Objectives The core objectives of this course are as follows: • Students will understand basic foundations of JavaScript, including its usage in the web and application design and development. • Students will understand basic foundations of Flash/ActionScript, including its usage in the web and application design and development. • Students will understand the foundations of mobile applications development.
Academic policies • Lab use • Communication about grades • Academic honesty • Exam and quiz policy • Late work
Assessment criteria • Assessments:Class participation - 4 Quizzes – 25 points eachJavascript Assignment 1 – 40 pointsJavascript Assignment 2 – 40 pointsJavascript Assignment 3 – 50 pointsActionscript Assignment 1 – 20 pointsActionscript Assignment 2 – 25 pointsActionscript Assignment 3 – 35 pointsActionscript Assignment 4 – 50 pointsFinal Exam – 100 points
Grades/Resources >= 90% A Excellent >=80% and < 90% B Above Average >=70% and < 80% C Average >=60% and <70% D Below Average < 60% F Fails Javascript, A Beginner’s Guide, 3rd Edition by John Pollock Foundation Actionscript 3.0 by Yard, Webster and McSharry
Contact details Email: mtovey@bumail.bradley.edu AIM: marktee07 Twitter: em_tee After lectures on Monday’s and Wednesday’s
Javascript Introduction
Javascript • Adds interactivity and effects to a static HTML page • Limited to client side actions • Wikipedia.com – no javascript interactions • Amazon.com – significant javascript enhancements
First steps.. • Tools of the trade • A text editorTextWrangler (http://www.barebones.com/products/TextWrangler/)Notepad++ (http://notepad-plus.sourceforge.net/uk/site.htm) • A browserFirefox (current version 3.5.7)Internet Explorer (version 7) • Edit code in your text editor • When ready to try your code, open in the browser
Simple HTML page <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN“ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Simple static page</title> </head> <body> <p>IM215 rocks</p> </body> </html>
First script Add the following to our page: <script type=“text/javascript”>document.write(‘<p>And so does Javascript</p>’); </script> Save the page and re-open it in your browser.
External script Create a new file and insert the following line: document.write(‘<p>Written in from outside</p>’); Save it as external.js Return to our original html file and insert the following: <script type=“text/javascript” src=“external.js”></script>
Variables Variables are containers for data datum – individual piece of data name - label that identifies the piece of datum variable – consists of a name and a piece of data A variable’s datum is called its “value”
Variables (cont.) Simplify code and save time, giving commonly referenced values a single name Acts as a placeholder for unknown values, e.g. user input Clarifies code, allowing you to give meaningful names to values used in code
Using Variables Defining:var variableName; Giving, or “Assigning”, a value: variableName=25;Or, combined:var variableName=25;
Variable rules Variable names are case sensitive. Can only contain letters, numbers or underscores. Cannot begin with a number. Cannot be one of a set of Javascript reserved words. Use meaningful names.
Variable Data Types • The current value of a variable has a “type” • Javascript has 3 core data types • Number – Any number including decimal numberse.g. var numVar=25; • String – any sequence of characterse.g. var stringVar=“A string of text”; • Boolean – true or false
Using Variables To reference a variable, include the name in the context of other code. For example,var ourString=“An assigned string”;document.write(ourString);
Comments Lines in code that get ignored by the JavaScript engine. Provide clarity, allowing you to explain the overall purpose of your code in plain english. Valuable when collaborating on code with others, and for your own future reference.
Comments • Single line:// This line is a comment • Multi-line:/*This is a multi-line commentEverything within here is ignored*/
Sources: “JavaScript: A Beginner’s Guide” by John Pollock