In this video, we take a step further into our object orientated programming,
Seeing where we will code along with a very high level overview of the different
elements we're working with. We will see just how it is possible to run our applications.
We actually get a look at certain things in detail, for example, I'm sure we will find
things in our output and compiler errors if we were to make a mistake anywhere in the coding.
Not to worry, this is a natural process and some mistakes and errors are expected to be
made. It's learning from those mistakes and actually bookmarking future solutions
that help you become a great developer.
We continue our steps along the path of Object orientated programming. We show you examples
and give you the exact run down of how to run our applications. Also, in the most likely case that
you become stuck or receive an error or caution warning, examples and solutions to your problems
are provided.
So, how do we actually get all these stuff set
up? So if we go back into our project files,
i'm just going to double click into it,
and I'm going to go directly to my source, into our
main.
If I click on our main,
it's going to open up, and I'm going to toggle back into
our
finder, and I'm going to double-click on our main.as
as well.
If I click into our main.as, we're going to see that this is
a file structure here that has some code in it, that is a prior written
amount of code that we are going to have there
always
until we learn a little bit more about
object oriented programming. We're just going to assume that that
has to be there always.
To make linkage between where we're going
to code
and our FLA,
we have to actually tell our FLA that our
stage from now on, our root,
our application hub, where our source code begins
is our main.as.
The way we do that, and the way we've done
it in our pre-loaded files is,
we type the name of our class directly into
our class property.
We got rid of the .as
because we don't need that,
and it wouldn't work if we would,
and we just typed... and it's really important
to note, uppercase M,
all the rest lowercase, everything
in Flash.
It's very very important to make sure that
you type it exactly the same way or things
won't work the way that you expect them to work.
So we have our linkage between our class and
our main.
Let's see how we could run our applications,
and obviously if we run our application right
now, because we said, we haven't done anything yet
and we just run it,
and that's another point that we have to
make sure. How do we run our application? So
far it was a magic that I was working on.
The way we run our application is going
through our control,
and then clicking on test movie, and enter.
Command enter would then run my application.
So, command enter is really how we want
to run our application most of the time as we're
testing our application.
As we run things, we're going to see things
in our compiler errors, and our output,
if we have any mistakes.
Let's link back to that. We saw the compiler error,
but if we go back now into our main.as and we know
that it's linked together, and the way we know
is, we have our class that is main,
and if we click on this edit class definition,
this pencil tool thingy,
and we click on it, it will take us
into our main.as. In our main.as, if we had any errors, let's
say we by mistake didn't add a bracket, let's
just delete this bracket,
and don't worry about what it is and why it's
there but it is has to be there.
If we try to run our application, again by clicking on our
command enter,
we're gonna see that we're going to automatically
get a compiling error which is going to tell
us that they're something that it's missing,
and we're not going to dig into right now, but it basically
means that we're missing what we have to have
there.
While if we run it with it,
then everything is fine.
So that was our compiling errors. Let's see how
we could trigger things into our output.
Now with that said,
it brings us to: where is the area that
we could type in?
I'm just gonna run through what we have
here really quickly,
and we're not really gonna dig too deep
into it right now because it's really early on.
We're just going to
assume that this always has to be
here, but let's just see this. Our package is basically
telling
Flash what directory our main is
sitting in. Right now, our main is sitting in
the exact same directory. We're gonna see how
we can work with setting it in different packages
in future videos.
For our sake and purpose, we always open a curly bracket
to kind of contain something. Everything
inside of this curly bracket area, and
i'm just going to highlight it,
everything inside of here is part of this
package.
Don't worry about what is a package. Now inside
of this package is, we're importing a movie clip
which is basically
our base foundation block, which is our root,
our application, where we're actually switching
our root to be our movie clip,
and a movie clip has all the functionalities
and all the code kind of built into it that
Flash needs to know how to run our application.
For now that's all we really need to know
about it.
Here, we're defining a new class which
is our new object.
I'm really running through it very very vaguely, and the
reason is because there's a lot of details
we would have to get into to be able to really
understand these things,
and in these intro videos, we're really not going
to touch object oriented programming,
but we're gonna work inside of the environment
of an object oriented program.
In other words,
what we're doing is,
we're defining a new object
that is then created dynamically as we're running
the application, we're creating a new object
and this object is actually our application.
Inside, between, as you could see your public,
function, main, open
round bracket close round bracket,
open curly bracket close curly bracket.
Between our open curly bracket and close curly
bracket of our main function is where we will
put all of our code from now on.
What I want to do is,
now that we know that, and don't worry about
it, really don't worry about why, just assume
that you just have to have all this, and all your
code has to come right here.
All your code has to come where I am typing
right now.
Now, i'm going to teach you a quick command
which in Flash is called a function.
We're gonna run our function, this quick function,
we're not going to go into the details of what
functions are, we're going to look at that in the
future videos in this release.
We're just going to see how could we trigger
things to output into the output panel, and
the way we do that, we're just going to type trace,
we're going to open a round bracket,
we're going to click on shift,
comma to create a double quote,
and we're going to type
very very cheesy,
the word's hello world, close our
quote, same type, double quote,
close our round bracket
and then put here a semicolon.
That's all we really need to be able to
run our first application. What this will do
is it's going to send this string, it's going to
send this value to our output panel,
and if I run my application, again using my
command enter,
I'm going to se in my output panel "Hello World", and it's not
part of our application, users can't see
it, but us, as we're testing our application,
we could see our "Hello World".
Now, we were working in our object
oriented world.
Obviously we haven't really dug much into
this world, and what everything here actually means,
What is a class? What is an object?
What is a movie clip?
What are functions, and why are we inside of a
function when we're making these calls?
What are packages, and so on? We're not really
gonna answer those questions in these initial
videos, we're just deliberately sitting inside
of the object oriented kind of
area to make it is easier, and kinda getting used
to being in there as we decrypt and slowly
slowly understand what are the different pieces
that are here.