In this video, we take a step further into our OOP programming, 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 learn two ways to run an application. We actually get a look at certain things in detail, such as the contents of a basic AS file, a 'package.' Hint: a package tells Flash what directory the OOP class "Main" is in. This video explains what a 'movie clip' is: it is contained in the package. Learn to define a new object that is created dynamically as we're running the application: the object is actually the application!
NOTE: Everything in Flash is case-sensitive: if you name a class "Bouncing_Ball" and later call it "bouncing_ball," you'll get an error.
I'm sure we will find things in our output and compiler errors if we make a mistake anywhere in the coding. Not to worry, this is a natural process and you can expect some mistakes and errors 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 OOP programming by learning how to send a value to the output panel. (Does "Hello World" sound familiar? ;) 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 this 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(OOP.) 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 to
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 because Flash is case sensitive.
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 to run our applications,
and obviously if we run our application right
now, and we haven't done anything yet
nothing will happen.
That's another point that we have to
learn. How do we run our application? So
far it was 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 it.
As we run things, if we have any mistakes, we're going to see things
in our compiler errors, and our output.
.
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,
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 realize it is has to be there.
If we try to run our application now, again by clicking on our
command enter,
we're going to see that we're going to automatically
get a compiling error telling
us that there is something that it's missing.
We're not going to dig into that right now, but it basically
means that we're missing what we have to have
there.
While if we run it with what is missing,
then everything is fine.
So that was our compiling errors. Let's see how
we could trigger things into our output.
With that said,
it brings us to: where is the area that
we could type in?
I'm just going to run through what we have
here really quickly,
and we're not really going to dig too deep
into it right now because it's really early on.
We're just going to
assume that this code always has to be
here, but let's just see this.
Our package is basically
telling
Flash what directory our main is
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 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 a package is. Now inside
of this package is, a movie clip we're importing
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 going to 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 words "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 send this string, this value to our output panel,
and if I run my application, again using my
command enter,
I'm going to see 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
going to 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 kind of getting used
to being in there as we decrypt and slowly
slowly understand what the different pieces are
that are here.