Start learning with our library of video tutorials taught by experts. Get started

EaselJS First Look

Creating a template


From:

EaselJS First Look

with Ray Villalobos

Video: Creating a template

It's always a good idea to setup a template when working with different technologies. The templates are a great guide and timesaver for new projects. Let's take a look at how my template is setup for Canvas and EaselJS. So I usually start by creating an underscore folder and inside that folder I create a JavaScript folder as well as a CSS folder. In the CSS folder, I place a stylesheet, this one is called style.css and right now it's empty. And in the JavaScript folder I place the script.js file which is also empty right now.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
EaselJS First Look
1h 28m Beginner Sep 21, 2012

Viewers: in countries Watching now:

EaselJS is a free JavaScript library that makes creating interactive web content for HTML5 more straightforward and intuitive. This course transitions web designers, animators, and content creators who may be used to working with Adobe Flash and ActionScript to this new open web standard. Author Ray Villalobos first explains the capabilities of the EaselJS framework and the HTML5 Canvas element, and what they mean for web design. The rest of the course shows how to use EaselJS's helper classes and hierarchal display list to load images, draw, animate, and handle mouse input from visitors.

Topics include:
  • Installing EaselJS
  • Understanding how Canvas draws and animates
  • Drawing lines and strokes
  • Drawing with graphic primitives
  • Using the chaining and compacting commands
  • Animating shapes
  • Working with text
  • Importing bitmaps and vector graphics
  • Working with sprite sheets
  • Handling mouse events
Subjects:
Web Web Design Web Development
Software:
CreateJS EaselJS
Author:
Ray Villalobos

Creating a template

It's always a good idea to setup a template when working with different technologies. The templates are a great guide and timesaver for new projects. Let's take a look at how my template is setup for Canvas and EaselJS. So I usually start by creating an underscore folder and inside that folder I create a JavaScript folder as well as a CSS folder. In the CSS folder, I place a stylesheet, this one is called style.css and right now it's empty. And in the JavaScript folder I place the script.js file which is also empty right now.

Our index file is a very basic HTML5 document. There is nothing special here. When we're working with Canvas or EaselJS we're going to need to add a canvas tag and give it an ID so that we can target it with JavaScript. We'll give it an ID of Easel here. It's also customary to put in a width and height for a canvas element. So I'm going to type in 380x480 just because it fits nicely on my screen right here. So the canvas is just a box that essentially contains a bitmap on your page. It's already there, but it's really hard to see, so I'm going to link this document to the stylesheet and make it a little bit more visible with some CSS.

So let's go into the head section and I'll add a link tag, give it a relation of stylesheet, and link it to our CSS file. So I'm going to save this and go into my CSS file and add some styles to make everything more visible. Now let's go ahead and target the Easel ID that we created in our HTML file. I'll make the margin 0 and auto just so that this centers if I make my window bigger.

And that's about all the styles we are going to need for this project, so I'll save this and we will probably never see the CSS file again. I'll also need to create a link to the JavaScript document. We're going to need to work with the Canvas after the page is finished loading. You can do this a couple of ways, but traditionally you can use an on-load handler and the body tag to trigger a function. So let's go ahead and modify our body tag. So now we need to go into our JavaScript file and create that function. I'll Save this into our JavaScript document and create this function.

So adjust the testings out, I'm going to type in a consol log command here and just print something out to the console. So I'll save this and coming right here and I'll refresh the page. Now nothing is going to show up. I'm going to right-click to select Inspect Element; this is going to work if you've a browser like Chrome or Safari. So right-click Inspect Element and you could see the developer tools. If you go to the console you should see a message that says JavaScript Loaded. That means that everything is hooked up correctly and your JavaScript is executing properly.

So I'm going to go ahead and remove this and save everything and we have a nice template to begin with. Creating a template is always a good idea and it's going to give you a good starting point for any of your projects.

There are currently no FAQs about EaselJS First Look.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Upgrade now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed EaselJS First Look.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked