Monday , 16 January 2017
Console Object

Console Object – Advanced JavaScript Tutorial

The console object is the recommended way to log errors, messages, and information about what’s going on. All browsers have consoles and are accessible via the console object. Clear your script and add this bit of code. [crayon-587cdef9d6c7a236183136/] To access the console object, will depend on your browser. If you have FireFox, then you must install firebug in order to …

Read More »
Try-Catch Statement

Try-catch Statement – Advanced JavaScript Tutorial

The try-catch statement is a unique way to handle errors. When errors occur, usually it would be logged into the console for you to see. This can be accessed in a variety of ways in different browsers. Usually you’ll find it in the developer section. The try-catch statement allows you to handle errors in your own way. Let’s clean up …

Read More »

Audio – Advanced JavaScript Tutorial

The video and audio objects both have the same events, properties and methods. So, you already know how to use most of things in the audio object. However, there are a couple of key differences when it comes to formats. Audio Tags To add audio into your document, then you use the <audio> tags like so. [crayon-587cdef9d8c08678104814/] Like last time, …

Read More »
Video Events

Video Events – Advanced JavaScript Tutorial

Video events allow you to tap into what’s currently happening with the video. There are a couple of video events, but we’ll only go over the more common ones. Let’s update our <body> tags to this. [crayon-587cdef9d9301518077981/] We added a button and a place to display the duration and the current time of the video. Let’s update our script to this. …

Read More »

Video – Advanced JavaScript Tutorial

Videos have finally become possible since the introduction of HTML5. It is VERY easy to work with videos as the good guys at W3C made a very simple API to use. Before you get started, please make sure to download the source code for this tutorial as it contains the video files for this tutorial. Video Tags Before we dig …

Read More »
Global Properties

Global Properties – Advanced JavaScript Tutorial

There are 2 global properties you can use to apply to your drawings. This the alpha and composition properties. They can truly effect the outcome of all your drawings. Alpha Clear your script and add this bit of code. [crayon-587cdef9da04d315039133/] In the example above, we draw a rectangle with the default settings. Next, we change the globalAlpha property. This property …

Read More »

Gradients – Advanced JavaScript Tutorial

Gradients allow you to create fills with multiple colors. Not only that, it takes care of transitioning from 1 color to the next. There are 2 kinds of gradients which are linear and radial. We’ll learn how to do both in this tutorial. Linear Gradients Clear your script and add this bit of code. [crayon-587cdef9da614756353451/] Alright a couple of things …

Read More »

Shadows – Advanced JavaScript Tutorial

Shadows are a great way to make your 2D drawings pop out. They’re very easy to set up and you’re given a couple properties to get you started. Clear your script and add this bit of code. [crayon-587cdef9daded556212411/] In the above example we use the 4 main shadow properties and draw a green rectangle onto the canvas. Let’s focus on …

Read More »
Drawing Images

Drawing Images – Advanced JavaScript Tutorial

If you would like to add your own images into the canvas, then you only have to write a couple lines of code to do so. There are a couple of ways of drawing images onto the canvas, but we’ll be using 1 way which is the image object. Please feel free to download the images I use in this …

Read More »

Transformations – Advanced JavaScript Tutorial

Transformations allow you to add cool effects to your drawings. This tutorial will cover that and we’ll fix the problem with fuzzy drawings. Fixing Fuzzy Drawings Previously, we set the width and height of the canvas using CSS. This is the wrong way to do things as it can actually stretch our drawings and make it appear fuzzy and blurry. …

Read More »
Text API

Text API – Advanced JavaScript Tutorial

In this tutorial, we’ll take a look at how to add text to our canvas. It’s actually quite simple. You’re given many options to set up how the text appears. Let’s update our script to this. [crayon-587cdef9dd06a548198598/] There are 2 methods to add text to the canvas. They are the fillText() and strokeText() methods. Both of these methods have the …

Read More »
Path API

Path API – Advanced JavaScript Tutorial

The path API allows you draw custom shapes with paths.  You can create some really complex shapes and drawings with this API as it comes with powerful methods. Lines Clear your script and add this bit of code. [crayon-587cdef9dd6d6309665628/] So, we first set up the stroke color and set it’s with to 2 pixels. Now, we can start drawing some …

Read More »

Canvas – Advanced JavaScript Tutorial

Since the introduction of HTML5, the <canvas> tag has grown a great amount of popularity. The <canvas> element allows you to draw graphics onto the document with JavaScript. To get started, let’s update our document to this. [crayon-587cdef9ddfb3068639243/] The very first thing we must do is create <canvas> tags. This is where all our graphics will be placed. You MUST …

Read More »
Text Fields

Text Fields – Advanced JavaScript Tutorial

In this tutorial, we’ll focus on text fields in our forms. There a couple of events, properties and methods to make working with forms easier. Selecting Text Let’s update our document to this. [crayon-587cdef9dea43521591099/] Alright, let’s clear out our script and add this bit of code. [crayon-587cdef9dea50684380021/] In our third line, we use a method called select(). This method will …

Read More »
Form Events

Form Events – Advanced JavaScript Tutorial

If you’ve seen my JavaScript tutorial series, then you already know how to work with forms. In this tutorial, we’ll talk a little more about form events  and how to manipulate them with JavaScript. Setting Up The Document Let’s update the body tags to this. [crayon-587cdef9df198500114391/] We just have a basic form with some input fields. You should remember that …

Read More »