| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Jul 2001
Location: South Korea
Posts: 39
|
hello~
I want to know a difference of __proto__ and prototype? and usage ^_^ I'll wait you reply.. thanks for reading |
|
|
|
|
|
#2 |
|
Meuh? MMeuh!
|
I'll try to answer you clearly...
First you have to have a little knowledge on class and object (so in OOP). In flash you can use now OOP. FIRST prototype: This property is used to affect some methods to a class you've made. i.e: ActionScript Code:
and use too to tell that your class is a lower class of another i.e: ActionScript Code:
So now to explain the __proto__ property I have to make a lower class from the Cycle Class. ActionScript Code:
Ok, now I create an instance of my class VTT; FirstVTT = new VTT(); Then if I write FirstVTT.roule; it works... Why? Simply because if the __proto__ property. This property give the class of the object... OK? Flash look for the FirstVTT class so it look on the __proto__ property and find VTT. But it can't find the "roule" method. So it look in FirstVTT.__proto__.__proto__ and find Cycle. It look for the roule and find it... execute the code. __proto__: which class prototype: define lower class and class methods. Hope it's not too confused! ![]()
__________________
I'm a froggy, so excuse me for my poor english Blog - Dev By MX For any jobs go on my blog on the contact page... |
|
|
|
|
|
|
|
|
#3 |
|
Thing
Join Date: Jun 2001
Location: UK
Posts: 2,418
|
Just incase you don't know too much about OOP......... this still isn't going to be easy in under 500 words but I'll give it a go!
Objects have properties, such as color, width, height etc. They also have MethODs [stuff they DO] such as play(),stop(),goto.... etc. They inherit these from the template they were made from (their Class). For example all movieclips have the same properties (_x, _y, _alpha, _rotation.......) and the same methods (play(), stop()......) because they inherited them from the 'movieClip Class'. If you make your own object then you have to create the Class (template) for it. When you create a Class, Flash automatically assigns that class a property of its own called prototype. Prototype holds a generic object, onto which you can attach any methods or properties that you want all instances of that object to share. Confused by that last bit? Well read on, it might clarify things....... You can also give existing objects new methods, so in more simple terms if you wanted to give every movieclip a new method called boogie (which would be accessed like this: movieClipName.boogie() ), you would add your method on to the prototype of the 'movieclip Class' so it can be shared by all instances ______________________________________________ __proto__ is a reference to the prototype property. I'm not so clear on this but I believe that if you have an instance of a movieclip called "Fred" then fred.__proto__ will equal: movieClip.prototype This allows the instance to check what inherited properties it should have. Hope this helps |
|
|
|
|
|
#4 |
|
Registered User
Join Date: Jul 2001
Location: South Korea
Posts: 39
|
I really thanks for your good reply ^_^
have a good time |
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2000
Location: Australia
Posts: 8,612
|
Everyone should read this ( http://www.debreuil.com/docs/ ) at least once.
__________________
Cheers Jesse Stratford ActionScript.org Cofounder Email: presented in this way to stop spam-bots: My email is composed of my first name (jesse) followed by my last name (stratford) followed by @ followed by actionscript.org Please don't email or PM me Flash questions, that's what the Forums are for! ![]() Please don't rely on me reading my PMs either. Email me about important stuff. |
|
|
|
|
|
#7 |
|
done
Join Date: Jun 2001
Location: portland, or
Posts: 8,048
|
jesse, we should all read it at least twice.
heh.
__________________
tg --- what the hell was i thinking? |
|
|
|
|
|
#8 |
|
(@_@) -("pretty lights")
Join Date: Sep 2001
Location: the Netherlands
Posts: 3,988
|
I did read it twice ... maybe I should read it a third time and make notes ... cuz its clear when I read it, but once I'm looking at that empty actions window ... *quiver*
__________________
RicoD Link ? |
|
|
|
|
|
#9 |
|
done
Join Date: Jun 2001
Location: portland, or
Posts: 8,048
|
ha!. believe me. i've read it more than twice also.
__________________
tg --- what the hell was i thinking? |
|
|
|
|
|
#10 |
|
Registered User
Join Date: Jul 2002
Location: Avignon, France
Posts: 29
|
There's a very good book : 'ActionScriptiong' written by Colin Moock.
Object are explained very easy. reùm |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|