View Full Version : prototype
grass
September 27th, 2009, 08:28 AM
hi,
here's a question... if i do something like that on some prebuilt class:
Object.prototype.func = function() {
//do smthng
}
//and then
var asd = {};
for(var i in asd) trace(i+" = "+asd[i]); //traces smthng like "function66 - function Function"
this is sortof a problem, as I use for-loops a lot... now as I understand prototype creates a dynamic variable - any chance there's a fix to that, so the prototype reference wouldn't be visible if I loop the object?
dnx
senocular
September 28th, 2009, 08:41 AM
Don't use prototypes?
... but if you must, then I think you're only chance is with Object.setPropertyIsEnumerable
http://livedocs.adobe.com/flex/3/langref/Object.html#setPropertyIsEnumerable()
grass
September 28th, 2009, 09:01 PM
1. doean't work... manual says: The property must exist on the target object because this method does not check the target object's prototype chain.
2. that's not exactly what I mean as I can't call it on Object anyways rather than on an instance...
3. Is there another cool way to add cool methods to Object and Array? (without creating a subclass! -I just love [] & {} way too much =)
rumblesushi
September 28th, 2009, 09:15 PM
Honestly I don't know why you would want to use prototype.
It was just AS1's basic handling of classes really.
There's no need for it, with AS3's excellent OOP structure.
grass
September 30th, 2009, 05:14 AM
dude! -I just explained in my last post why!!!
Instead of giving false credit to a obviously far from perfect new version of the language, answer the damn question!
rumblesushi
September 30th, 2009, 08:21 AM
lol
senocular
September 30th, 2009, 08:46 AM
For the record, getting rid of prototypes (or the common use of them) was a step closer to perfection, not one further away. Simply, you shouldn't be using them in AS3, especially not for native classes.
grass
October 19th, 2009, 02:16 PM
well dude, if writing 4x more code is PERFECTION then you say mr. Saint-Exupéry was a retard...
perfection ain't, when there's nothing more to add but when there's nothing left to take away...
var o:Object = new Object();
//vs
var o = {}
hmmm.....
Also guys: one of the biggest mistake of AS3 was the pushing of classes. Now, don't get me wrong, object orientation is the S! however, earlier a flasher didn't have to be a coder to do some cool sites... they could just use simple syntaxes like onreleases etc.
And now... well, there's a lot of useless code and things are rather complicated than simple (some improvements i see, granted)
anyhow - I defended flash a lot before (till f8) and still, it's the ONLY proper scipring front in web... 4 now - the lack of competition has just made you guys... ... ... ;)
no disrespect intended =)
dandylion13
October 19th, 2009, 07:06 PM
Hello grass :)
I would just like to politely point out that if you insult forum members who take the time to try and help you with your problems or answer your questions, you're not going to win any friends around here and no one will want to help you.
Because this forum is for the discussion of AS3.0, you'll tend to get an AS3.0 perspective on things so I'm sorry we haven't been able to help.
-d13
grass
October 21st, 2009, 10:43 AM
wow... rly =|
mr dandy, 1st - if you wuz insulted by that, u'r a major wuss (or just don't understand eng.)!
2nd: spamming is not the way, if u have nothing productive to say, plz ignore my topics, DNX!
glosrfc
October 21st, 2009, 11:14 AM
wow... rly =|
mr dandy, 1st - if you wuz insulted by that, u'r a major wuss (or just don't understand eng.)!
Gosh, is that what passes as English nowadays?
Let me say that I do have some sympathy with your viewpoint regarding unnecessary code. Being reasonably competent in AS 2.0, I'm reluctant to abandon that knowledge and devote time and effort to relearning it all over again. And it is true that there were *some* cool sites created in earlier versions of Flash; both using AS 1.0 and AS2.0 along with Flash's idiosyncratic button events.
It's also true that there was (and still is) a lot of dross created as well. But there are right and wrong ways to elicit assistance - particularly when you've already received a definitive answer from the "dude".
wvxvw
October 21st, 2009, 12:55 PM
OK, I'm sorry to post that insulting image... but you also have to admit, that if I would only post a link to it, the effect would be entirely different :(
senocular
October 21st, 2009, 01:28 PM
the image was just too big
Iamthejuggler
October 21st, 2009, 02:11 PM
what image? I missed it ... damn it!
grass
October 30th, 2009, 08:44 PM
just to CLOSE this cool topic I wanna point out I'm so totally insulted by wvxvw's image, that was obviously too big to fit the picture... and feel really bad that you didn't like me. Gonna go to politeness-school asap
cheers!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.