Yea without a teacher it can be really hard to learn, ultimately in any book your going to run into points where they didn't write it in a way that makes sense to you so you need someone to explain it in a different way.
In general programming in Object Oriented Design.
That means everything in your program is treated as an object and to be incredibly simple it basically results in hierarchy maps.
like this
http://www.google.com/imgres?q=class+hierarchy+diagram&um=1&hl=en&sa=N&biw=853&bih=414&tbm=isch&tbnid=6lUWG0fy2-5hUM:&imgrefurl=http://inkscape.org/doc/devdocs.php&docid=zurQG1vomJAM&w=843&h=505&ei=UiBQToGAL4mHsgKgmMjIBg&zoom=1&iact=hc&vpx=538&vpy=102&dur=378&hovh=95&hovw=158&tx=201&ty=91&page=1&tbnh=95&tbnw=158&start=0&ndsp=8&ved=1t:429,r:3,s:0
in there you can see the really big thing is called GObject at the top.
its a class and each class has members, in this case its
SPObject, SPEventContact, SPview & GTKObject
so when someone wrote the code what they wrote was this (roughly its pseudo code not real code)
class GObject
{
public members:
SPobject();
SPEventContact();
....
....
}
now to make this a little easier to understand instead of GObject, assume its a ball.
class Ball
{
public members:
SetRadius(x);
myRadius();
private members:
radius;
}
ball.SetRadius(x)
{
radius = x;
}
the way we would make a Ball in our program is first to declare a variable
Ball myPersonalBall;
now we've made a ball, MyPersonalBall is the name, Ball is what it is similar to if i was to declare you i'd write
human callmedata;
your a human, but there are many humans, i'm specifically talking about you.
now if i want to set a balls radius i write
myPersonalBall.setradius(10)
that sets the radius to 10
set radius is a member of myPersonalBall, more generally its a member of all balls, thats the point of a class. A class is a generic item, every human has a nose and every ball has a radius.
Anytime you type
myPersonBall.setRadius(some number)
what your basically doing is saying earlier I defined what members balls have, done here.
class Ball
{
public members:
SetRadius(x);
myRadius();
private members:
radius;
}
now SetRadius just typing that doesnt do anything, its just some meaningless combination of words, if we want it to do something we have to define it, done here
ball.SetRadius(x)
{
radius = x;
}
now we've basically said anytime i type
myPersonalBall.SetRadius(10);
what i'm saying is, in my personal ball there is this member called SetRadius find that member, now i've defined that member and said what it does, it takes whatever number I put in parenthesis and makes it the radius. so go do that with the number 10.
now if we look at your line of code this is what we see
if (animation) animation.Play(aniClip.name);
your going to have to take some of this as true right now and learn why later but an easier way to view it is as multiple lines.
if (animation)
{
animation.Play(aniClip.name);
}
an if statement can only be true or false.
if true it does the stuff after it (the stuff in the brackets).
if false it skips those lines of code and goes past it.
so that means if what is true? well if animation is true.
that sounds odd but somewhere animation is defined as what's called a boolean value which is something that can only be true or false.
what they probably do is something like
if we want to play an animation
animation = true;
if we dont want to play an animation
animation = false;
then they test animation later on (in your line of code) to find out if they should play it
if they should (it's set to true)
do this
{
animation.Play(aniClip.name);
}
now from what you read and hopefully understood earlier we can see that
animation is class and it has a member called play, also aniClip is itself a class that has a member called name
the code they wrote should look like this.
class animation
{
public member:
play();
}
animation.play(theNameOfAnAnimation)
{
code for play, presumably it plays this animation but it wants you to tell it the name
}
class aniclip
{
public members
name();
}
aniclip.name()
{
code to return the name of the animation
}
so
animation.Play(aniClip.name);
were calling the play member of animation, but just like when we called setRadius,
myPersonalBall.setRadius(10) in that case we had to give it a number(10).
well in this case play requires a name, we know that it requires a name because clearly inside the parenthesis a name is being given to it so it must need it.
we get that name by looking at clip and calling its member name.
Not the best teacher hope that makes sense best of luck
Please respond to answers with comments. Also if you like an answer, choose it as The answer. Don't bother with ActionScript unless you are going to be doing Flex or Flash stuff. I mean, it's similar, but might just get in the way. IMHO programming is mixture of two things: recognizing patterns, and telling a story with math. Much too big a subject to go on about, and it's been so long since I learned the basics, I wouldn't know what's a good book out now, sorry. But there is tons of stuff, video, tutorials, etc. Best of luck.
– DaveA