Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rate Thread Display Modes
Old 07-20-2002, 03:44 AM   #1
ryuyu
Registered User
 
ryuyu's Avatar
 
Join Date: Jul 2001
Location: South Korea
Posts: 39
Default __proto__ and prototype..?

hello~


I want to know a difference of __proto__ and prototype?

and usage ^_^


I'll wait you reply.. thanks for reading
ryuyu is offline   Reply With Quote
Old 07-20-2002, 04:50 AM   #2
xxlm
Meuh? MMeuh!
 
xxlm's Avatar
 
Join Date: Sep 2001
Location: Auckland - New Zealand
Posts: 3,050
Send a message via ICQ to xxlm Send a message via AIM to xxlm Send a message via MSN to xxlm Send a message via Yahoo to xxlm
Default

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:
//class constructor function Cycle (longueur, couleur) {     this.longueur = longueur;     this.couleur = couleur; } Cycle.prototype.roule = function() {this._x = _x + 20;}

and use too to tell that your class is a lower class of another i.e:
ActionScript Code:
Myclass.prototype = new MovieClip(); //or what you want...button..comboBox...

So now to explain the __proto__ property I have to make a lower class from the Cycle Class.
ActionScript Code:
VTT.prototype = new Cycle();

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...
xxlm is offline   Reply With Quote
Old 07-20-2002, 11:47 PM   #3
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

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
Mortimer Jazz is offline   Reply With Quote
Old 07-21-2002, 02:09 PM   #4
ryuyu
Registered User
 
ryuyu's Avatar
 
Join Date: Jul 2001
Location: South Korea
Posts: 39
Default thanks..

I really thanks for your good reply ^_^

have a good time
ryuyu is offline   Reply With Quote
Old 07-21-2002, 03:14 PM   #5
xxlm
Meuh? MMeuh!
 
xxlm's Avatar
 
Join Date: Sep 2001
Location: Auckland - New Zealand
Posts: 3,050
Send a message via ICQ to xxlm Send a message via AIM to xxlm Send a message via MSN to xxlm Send a message via Yahoo to xxlm
Default

__________________
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...
xxlm is offline   Reply With Quote
Old 07-22-2002, 02:13 AM   #6
Jesse
ActionScript.org Founder
 
Jesse's Avatar
 
Join Date: Nov 2000
Location: New York
Posts: 8,736
Default

Everyone should read this ( http://www.debreuil.com/docs/ ) at least once.
__________________
Cheers

Jesse Stratford
ActionScript.org Cofounder

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.
Jesse is offline   Reply With Quote
Old 07-22-2002, 03:02 PM   #7
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

jesse, we should all read it at least twice.
heh.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 07-23-2002, 12:56 PM   #8
Ricod
(@_@) -("pretty lights")
 
Ricod's Avatar
 
Join Date: Sep 2001
Location: the Netherlands
Posts: 3,982
Default

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 ?
Ricod is offline   Reply With Quote
Old 07-23-2002, 02:19 PM   #9
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

ha!. believe me. i've read it more than twice also.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Old 07-23-2002, 02:59 PM   #10
pandareum
Registered User
 
pandareum's Avatar
 
Join Date: Jul 2002
Location: Avignon, France
Posts: 29
Default

There's a very good book : 'ActionScriptiong' written by Colin Moock.
Object are explained very easy.

rem
pandareum is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:55 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.