View Full Version : Which do you prefer?
Logic
08-25-2006, 06:39 PM
Using functions or methods? I mean, you don't even need methods, but they make things a lot more convenient.
Any preference?
Insane Knux
08-25-2006, 06:43 PM
Prolly functions, for me.
Logic
08-25-2006, 06:50 PM
I usually only add methods to supported classes in Flash so that they match with JavaScript for convenience. I mean like:
String.prototype.replace = function(str) {
//coding
}
The .replace(str) method in JS is useful so I put that in and some others, but then I usually only do functions. I think they're more portable.
Freddy
08-25-2006, 06:55 PM
See I feel retared now.
I dont know the difference. =/
I just go with whatever works. 'course, Im not nearly as skilled in AS than a lot of you.
Logic
08-25-2006, 07:23 PM
A method is like a function that you attach to a specific class. You can see this by writing this line of code:
Selection.getFocus();
It uses a method "getFocus()" in the "Selection" class (built-in Flash), and then returns the user's focused area.
A function requires you to supply input...it's kind of weird to explain, but you see how the "Selection.getFocus()" has the "Selection" attached to it? With a function, you would have to supply that.
If you still don't understand, I'll give you an example in my next post.
I use functions alot more.
The Brown Cow
08-27-2006, 09:19 AM
Since I usually write object oriented code, I tend to use methods a lot more. But Flash treats them more or less the same way.
vBulletin® v3.7.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.