02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Are Classes Visual

One of our students in our live session asked are classes always visual or refer to things that are visual. the short answer is no but we explore this answer in detail and see a live example of it.

Video Transcript

00:00All right, so question number two.
00:02Can you create a class blueprint for other classes
00:05instead of for an object?
00:08Could you redefine that question?
00:11By the way, welcome whoever is, I think, Dan,
00:14welcome to the session.
00:17Oh, of course, of course.
00:18A class has nothing to do with visual.
00:21It's just easier to talk about something visual
00:23because then it's easy to see it.
00:25But a class could be visual or it
00:28could be saying that it's completely abstract.
00:30Or just try, for example, a math class or whatever class.
00:33It's just easier to, a class is really just
00:37a bucket for a conceptual idea in the exact same way.
00:43And really, when you're working, sorry, the question
00:45was how do you instantiate the blueprint then, right?
00:48When we're building a class that's completely,
00:52and let me just do this in Flash for a second.
00:54Let me just minimize this for a second.
00:57Not going to compile it, but let me just open here
00:59a new AS3 file.
01:02Oops, just an action script file, actually.
01:10Open a reset, no, no.
01:16All right, so, what, what, oh, yeah, that would do that.
01:19Okay, so basically, an object is nothing visual, right?
01:23But an object is a class.
01:24When I create a new object, done,
01:27I just created a new object.
01:28And this object is not visual in any mean or form.
01:33Now, on the other hand, if I had something visual
01:35in my library, if I had something in my library
01:37that was a class as well, that had a linkage to a class,
01:40such as our function creator here,
01:42whenever I would actually create a new L function creator,
01:47I would create that visual instance.
01:49It wouldn't be on the stage yet,
01:50because I would still have to actually then tell
01:52that visual element that I created, add me to the stage.
01:56So if you look at my spaghetti code, actually,
01:58in this presentation, if I just find it right here,
02:01we could see that I have your, a little bit of code here,
02:03and if I go to my, if we go to the actions script itself,
02:07we're gonna see that all I'm really doing here is I'm,
02:11let me, actually, let's find the, when I create it,
02:13which is, I think, right here.
02:16So basically, I'm creating in a loop,
02:18I'm creating a function, I'm creating here a function,
02:21creating a new movie clip, which is that element
02:23that's in the stage, which is also a class.
02:25And then I'm adding that child into a specific instance,
02:30a specific visual element on our stage.
02:33And it's that simple, okay?
02:35So obviously, the details, obviously, are,
02:38we get more into depth into how exactly the specifics
02:41of doing it in our videos on the website,
02:44but the idea behind a class is a class is just a bucket,
02:46has, it could be visual, it could not be visual,
02:49it has, it doesn't have to be visual at all, okay?
02:53Did that answer your question, Adam?
02:58Oh, yeah, yeah, it's done, it's an object now.
03:00At this point, after the new blue itself
03:02is an object already, absolutely.
03:05Visual or not visual, done, you just created
03:07a new object from a class.
03:08Now, if it was visual, then you'd wanna add it to the stage.
03:12It's not visual, done, you just created an object
03:14and you could start interacting with that object.
03:16And again, because you had that API thing,
03:18now you're only gonna need to know about
03:20the stuff that you need to know about
03:21and you don't have to know how it was actually built.
03:24Just for example, because I know that you use tweenlight.
03:26A lot of functions in tweenlight.
03:28But you have no idea about how they actually work.
03:30All you know is that you call the function to or from
03:33and an animation happens.
03:35And that's exactly the whole point
03:36of object-oriented programming where
03:38you don't have to know what happens behind the scenes
03:40and even preferably, you shouldn't know
03:42because all you really need to know
03:43is that you got something that works
03:44and you just have to call one, two, three, four functions
03:46and they do everything for you.
03:48Okay, and even if behind the scenes
03:50there's 300 functions that actually make it happen
03:52and sometimes more objects and more classes
03:54that actually make it happen, okay?
03:57All right, so let's push on.
04:02That is nested classes.
04:06There's no such thing really as a nested class.
04:08You mean inheritance,
04:12like a class that extends another class, right?
04:18We're gonna touch a bit about inheritance
04:22a little bit later.
04:22So it's actually our next topic.
04:24So let me try starting that up
04:26and then we'll see if that one not.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!