|
||||||||||||||
. . . . . |
Interfaces in Actionscript 2.0The Flash MX2004 AS 2.0 reference Docs state this for interfaces:
What does it all mean ? Well bear with me and I will try and make it understandable. Interfaces look like classes except for the keyword "interface" instead of class in it declaration. All of the methods will contain no code, just declarations. When you create a class that uses the interface , you include the keyword "implements" then the interface name. Lets show you an example. First we will create a Moving class:
interface Moving{
public function move();
}
Now we want to create a class that will use our interface:
class Spaceship extends MovieClip implements Moving{
// this class must at least declare all the
// methods of Moving
public function move(){
ship_mc._x += 10;
}
}
Flash Tutorials in Video Format -
Watch them now at LearnFlash.com Go to Flash and create a movieClip of your spaceship and in the linkage panel, type "Spaceship" in the identifier textfield. Type Spaceship in the AS 2 class field. And to call it, in our Flash Actions Panel type something like:
attachMovie("Spaceship", "myship",1);
_root.onEnterFrame = function(){
myship.move();
}
|
|
||||||||||||
|
. | Home | Flash MX | Actionscript 2.0 | Flash 3D | Flash 8 | Flash Database | Flash Mobile | Flash CS3 | Java For Kids | Video Course | General Video | Photoshop | Web Design | Digital Photography | Games | free backgrounds | Resume | Streaming Video | Students Work | Links | Contact me | sitemap | reviews | . . |
||||||||||||||