Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this movie I'm going to explain how to take an existing class like movie clip and extend it, or to take all the things the already exist in the movie clip class and add to them in your own custom class. The reason that you'd want to do that is so that you don't have to invent your own class that has a timeline at all that stuff. It's already all done for you. So just take it and build on it. So the first thing I'm going to do is after the word class, and by the way I'm in CustomClass.as, and that's the file that we built in the last movie.
You can find it in the chapter 05 working files. After class CustomClass I'm going to type a space, and then the word extends and then a space and then movie clip with a capital M and a capital C. class CustomClass extends MovieClip. That means custom class takes everything that's in the movie clip class, the timeline, the way that you can position them, how they animate independently, and we're going to add to it.
Now as is, this is not going to run properly because we need to do something called import. After the word package and after the open curly brace on line 2, you want to press Enter twice and then the up arrow, and then I'm going to type imports flash.display .MovieClip with a capital M and a capital C, And then a semicolon. With this line of code does, the line we just wrote on line 3, is it brings in all the information about movie clips, so that we can utilize it in this class.
If we do not have this line, then we have no right to extend the movie for class because Flash is not to know what we're talking about when we use the word movie clip. We need to import that information. So if you're going to extend a class or if you're going to use information from any class in an external file, you need to import that class. And that is how to extend the movie clip class. In the next movie we'll write some custom functions to build this class more fully and make it more unique.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101773 Viewers
61 Video lessons · 88535 Viewers
71 Video lessons · 72348 Viewers
56 Video lessons · 104059 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.
Your file was successfully uploaded.