ForumsProgramming ForumAS3 New Class Question

12 3367
kevinseven11
offline
kevinseven11
36 posts
Nomad

To my understanding you dont even have to make your own class, but it will just make the code run smoother? It sounds wrong but Im not sure.
Thanks.

  • 12 Replies
Captain_J_Sheridan
offline
Captain_J_Sheridan
313 posts
Nomad

Although I don't see the logic, but just like in C++, it's probably faster, or else, why go trough all the trouble?

dank
offline
dank
983 posts
Peasant

Why would you ever want to make a game without the use of classes? Its one of the many reasons why game programmers use OO languages.

Captain_J_Sheridan
offline
Captain_J_Sheridan
313 posts
Nomad

I guess he's talking of making his own class

I don't get the logic, you spend more lines and have to make a call for an external resource, how can it be faster?

Kurt5
offline
Kurt5
27 posts
Nomad

From what I get, making your own classes in AS3 simply makes the code or game or whatever run faster and avoid any errors because things are spelt out within the actions. I'm still learning but, most of what I understand so far says there not nescesary but usefull.

kevinseven11
offline
kevinseven11
36 posts
Nomad

okay so the whole

package kevinseven11spackage {
public class kevinclass {
//Blah blah
}
}

is kinda an option to learn becuase cant you just use the built in ones for literly everything?

dank
offline
dank
983 posts
Peasant

Yes, kinda, but AS3 is OO for a reason, plus it's a lot more efficient to write and debug code that has been properly written using OO programming methods. Before you think of coding any sizable game (anything over 200 lines), you should know what objects, classes, packages, interfaces, inheritance, encapsulation, and polymorphism are how to implement them.

jdoggparty
offline
jdoggparty
5,860 posts
Nomad

It does run a lot faster when you make your own class. It's weird/

PixelSmash
offline
PixelSmash
566 posts
Nomad

I don't know about speed, but the idea behind OOP is that you can reuse programming / classes. Good OOP can use 30-60% more time to write, but it's easier to debug, and when written right, it can be reused often - which saves time on a new project.

herofmb
offline
herofmb
30 posts
Nomad

Like Dank and PixelSmash said, by fully using OOP features, your code will be easyer to write, debug and reuse. But all these facilities have a price. To implement objects, their methods and atributes, you'll need tables in memory to store what methods and atributes belongs to what objects, and so on. That means that a non-OOP language, like C, is faster and needs less memory usage, but it is also more complicated to write complex code. That's why, even having to pay the price for the OOP, large companyes develop their softwares using OOP languages.

kevinseven11
offline
kevinseven11
36 posts
Nomad

alright thanks guys, I guess I will learn more about classes and more.
Thanks.

Captain_J_Sheridan
offline
Captain_J_Sheridan
313 posts
Nomad

I finally got how classes work, it's like making a index of a book, so you don't have to read the whole book to find something, where the chapters would be functions you programmed yourself

And you can initialize variables inside the functions, so you can spare memory on that too

KhimaeraUK
offline
KhimaeraUK
24 posts
Nomad

I don't get the logic, you spend more lines and have to make a call for an external resource, how can it be faster?


Following on from whats already been said, (resuable classes etc.)

In a massive application or game the source would be impossible to navigate if it was all written in one long file. With semantic class names it's much easier to work on a project (especially if you're working in a team).
Showing 1-12 of 12