Copy link to clipboard
Copied
Hey, you guys. I'm unsing FlashDevelop to code an SWF file that plays in flash. I'm new to using the Document Class and was wondering if anyone could explain to me what the following code means?
import flash.display.MovieClip;
and
What does "public class" and "extends MovieClip" mean in the following code:
public class as3documentclass extends MovieClip
Can someone explain what any of this means??
thanks in advance ![]()
Copy link to clipboard
Copied
I am not a knowledgeable person when it comes to class matters, but I think I can answer this to a reasonable level.
"public class" identifies the "as3documentclass" class as being something accessible to the outside world. Often there will be public and private differentiation, where private is not accessible to anything outside of the class. So a function within the class definition could call on a private element within the class, but you would not be able to do so from some other code source. I do not know of instances where a "private class" definition would be useful (or practical), so I'll leave that to someone who knows better to dwell on.
As for the "extends MovieClip", it essentially means that the "as3documentclass" is using the built-in MovieClip class as a baseline definition and whatever else the class code does is extending the properties/methods of the MovieClip class. A silly example, but consider a freshly baked chocolate cake as the MovieClip class, and your "as3documentclass" adds the frosting and decorations that extends the chocolate cake, turning it into a birthday cake.
Copy link to clipboard
Copied
Help files in flash are really useful. I used them to learn flash without the need of much online tutorials. You can start reading about classes. Have you ever created a class and do you know Object-Oriented Programming (OOP)? The import keyword is used to sort of include a class so that you can use it. The flash.display part means the package MovieClip resides in folder flash/display relative to where flash has defined its default class path. Classes can have these attributes as documented in the help file:
ActionScript 3.0 allows you to modify class definitions using one of the following four attributes:
Attribute | Definition |
|---|---|
| Allow properties to be added to instances at run time. |
| Must not be extended by another class. |
| Visible to references inside the current package. |
| Visible to references everywhere. |
The extends keyword means that as3documentclass inherits from the class MovieClip. In C++ language that would be written something like:
void* as3documentclass(somearg*)::as3documentclass : MovieClip
As i said, help files are really useful, trust me you will learn a lot from it than just tutorials because they explain very basic concepts and clarify alot of stuff that tutorials may fail to do since they go directly to the hands on example parts.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more