JavaScript – more arrays, images. Image Object and images[] array  Using allows us to display images on webpages. What if we want more control of what.

Slides:



Advertisements
Similar presentations
Tutorial 5 Windows and Frames Section A - Working with Windows.
Advertisements

Bring Life to Your Web Pages with JavaScript and HTML5 Ole Ildsgaard Hougaard -
Using Thread for Animation. Threads When we are doing multiple things at once we say we are multitasking Computers multitask when they run several programs.
JavaScript Arrays Arrays allow us to store lists of items Arrays are created with square brackets:  var a = []; // an empty array  var b = [10]; // an.
Tonight’s JavaScript Topics 1 Conditional Statements: if and switch The Array Object Looping Statements: for, while and do-while.
If there where no schools Travelling. The first person stamps with the right foot 4times with the heel on the ground, in a sitting position on a chair.
JavaScript- Processing HTML Forms. Event Handlers Begins with and ends with.
JavaScript- Introduction. What it is and what it does? What it is? It is NOT Java It is NOT Server-side programming Users can see code It is a client-side.
Chapter 16 Dynamic HTML and Animation The Web Warrior Guide to Web Design Technologies.
Javascript Document Object Model. How to use JavaScript  JavaScript can be embedded into your html pages in a couple of ways  in elements in both and.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Iteration Principles Once is Not Enough lawrence snyder c h a p t e r 21.
 2008 Pearson Education, Inc. All rights reserved Document Object Model (DOM): Objects and Collections.
Computer Science 103 Chapter 4 Advanced JavaScript.
JavaScript, Third Edition
Random Sampling using RAN#. Random Sampling using Ran# The Ran#: Generates a pseudo random number to 3 decimal places that is less than 1. i.e. it generates.
Introduction to JavaScript for Python Programmers
JavaScript Switch Statement. Switch JavaScript Switch Statement If you have a lot of conditions, you can use a switch statement instead of an if…elseif…
Lesson15. JavaScript Objects Objects encapsulate data (properties) and behavior(methods); the properties and the methods of an object are tied together.
“But I don't want to be a “programmer!” ActionScript for journalists Presentation by Mindy McAdams Flashjournalism.com.
Animations Flash ActionScript Introduction to Thomas Lövgren
JavaScript Events and Event Handlers 1 An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells.
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
Loops Doing the same thing over and over and over and over and over and over…
Unobtrusive JavaScript
THE BIG PICTURE. How does JavaScript interact with the browser?
History, Navigator, Screen and Form Objects Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Creating Web documents JavaScript: modeling dog behavior general modeling concepts JavaScript review.
Announcements Assignment 9 is due Project 2 is due 7/27/04 We will be skipping chapter 22 Test 3 (chapters 18-21) will be on 7/29/04 Tip of the Day : Functions.
Manipulating the DOM CST 200 – JavaScript 3 –
Name: Read this page first. A web browser is software on your computer that lets you visit web pages. The address bar is a box in a web browser displaying.
Chapter 5: Windows and Frames
Chapter 7: DHTML: Object Model and Collections CIS 275—Web Application Development for Business I.
Learning Unity. Getting Unity
JavaScript – loops and arrays. Arrays as cubbyholes  Array is an ordered collection of data  The content in the array is sometimes known as the array.
Topic 7 Temporal Control. 2Chapter 25 - Temporal ControlOutline Goals and Objectives Goals and Objectives Introduction Introduction Timeline Animation.
DOM Animation Changing the DOM objects over time.
THINKING BIG Abstraction and Functions chapter 6 Modified by Dr. Paul Mullins for CPSC 130, F05.
1 JavaScript
ECA 225 Applied Interactive Programming ECA 225 Applied Online Programming images.
A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University ©2011 Pearson Prentice Hall ISBN Chapter 17 JavaScript.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
JavaScript, Fourth Edition Chapter 4 Manipulating the Browser Object Model.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
JavaScript – return function, time object and image rollover.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Working with Windows (No audio component) © Dr. David C. Gibbs
JavaScript Functions A function is a block of code that can be reused. It is similar to a method in Java. It consists of a function name, an argument.
The Web Browser Button Game Click to play Click to play.
By Mrs. Morrison, 2 nd grade teacher and her students. All steps were completed by the students with some assistance from Mrs. Morrison.
Browser. What parts does the browser consist of? Title bar Menu bar Toolbar Address box Links.
Tutorial 11 1 JavaScript Operators and Expressions.
Working with the Window Object JavaScript considers the browser window an object, which it calls the window object.
Check Boxes. 2 Check boxes  Image from:  HTML:  Each box gets it's own.
Introduction to TouchDevelop Lesson 3 – Comments & Lists Created by S. Johnson
JavaScript and Ajax (JavaScript Functions) Week 5 Web site:
Loops Pretest var i=1, sum=0; while (i
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Introduction to JavaScript DOM Instructor: Sergey Goldman.
Objective of the lesson Use Blockly to make a dice for Snakes and Ladders All of you will: – Make an image which displays when you press a button Most.
Changing CSS Styles via JavaScript No readings?. 2 Review? You can change the CSS styling of an element with JavaScript Syntax is similar to accessing.
COM621: Advanced Interactive Web Development Lecture 6 – JavaScript (cont.)
© 2015, Mike Murach & Associates, Inc.
By Sanjay and Arvind Seshan
setInterval window.setInterval (statement, interval);
..J.ACKPOT. 13,
BBC Microbit.
اختر أي شخصية واجعلها تطير!
Building a Game with Unity3D
1 To go to the next slide, click this button instead. A random slide will come up.
Web Programming and Design
JavaScript Session III
Presentation transcript:

JavaScript – more arrays, images

Image Object and images[] array  Using allows us to display images on webpages. What if we want more control of what to show.  When a webpage with images is loaded by a browser, an images[] array is created. The first image is loaded onto images[0] and so on.  Unlike, GUI such as buttons etc, where they are the properties of the form, images are properties of the document.  In order to display an image using javascript. The command is straight forward as such. document.images[0].src= "abc.gif"

Object Hierarchy for images

Medium exercise: jex12.html

Medium Exercise  Instead of 4 buttons, you only have one now.  When you press the button, it will randomly select a picture  When you press random rotate, it will randomly pick a picture to display after a set interval  Stop random, will stop this process.

To get a function to repeat  The command to do that is stopID=setInterval("f1", 1000)  which means after every 1000 milliseconds, you will call function f1() again.  In order to stop the animation, you do the following clearInterval(stopID);  Where do you put this setInterval and clearInterval function?

How to include the rotation  You need to write two function and declare a global variable. var stopID // together with other variables //declaration function rotatePicture() { stopID = setInterval("disFirst()", 500); } function rotateStop() { clearInterval(stopID); }

Marquette Jackpot: jex13.html  Create 3 random image  Stop the image from rotating  When you stop and the 3 images displayed are the same you alert “JACKPOT”  Good Luck  Hint: You might want to rotate slower initially to know you can stop in time to see you hit the jackpot.