Monday, 16 June 2014

Inheritance in ActionScript

Not a big deal, though, I wouldn't wanna skip this. Inheritance is a concept of extending the properties and methods of one class to another using the keyword extend. Again, it is as how java works. The child class can have its own methods and properties and can use the properties and methods of the parent as well, provided the members of the parent class (properties and methods) are declared non-private. Just on a lighter note; it is possible to override the behaviors of a parent class within the child.

Atleast, that is what I know! Since most of the classes that we are gonna use will follow inheritance, I am not gonna spend much time explaining this. However, if you wish to know more about inheritance, grandfather's (GOOGLE) always thr!! ;-)

Read more ...

Saturday, 14 June 2014

Classes and OOP

So.. What are classes and what is OOP?

To give you a simple definition, Classes are templates/blueprints which has properties of itself and behaviors.

Properties are the variables declared within the class and behaviors are the functions/methods within the class. You will get the idea behind this when you create one.

OOP (Object Oriented Programming) is a programming technique where the code is written with reference to objects (instances). Object based programming technique in other words.

Java experts would find this easy to grab and I know its kinda crazy definition for them to agree; fortunately, this is my understanding :-)

Alright, without wasting any more time in theory, lets move on to practicals. Creation of our first class in Flash Builder.

Now, open Flash Builder and create a new ActionScript project

Give a project name for our new project. I ‘m gonna name it ‘Initialize_Test’. Just leave the rest of the options to default and click on Finish. Lets get into the details of the options later.

Sometime Flash Builder prompts the user to switch to the Flash Perspective view. Just click on ok, if prompted.

Your project will automatically be created with the default files. Before starting to write the code, we would need to add the wmode parameter in the ‘index.template.html’ file which will be present in the template-html folder. WMODE is a parameter which is passed to the < embed > tag in the html page that we are gonna create. This parameter has to be set to ‘direct’, meaning we are going to bypass the browser and perform our actions within the animation though the animation that we create is embedded in the browser. Simply put; the best way to access animation files within a browser.

Now, open the Initialize_Test.as file and paste the below code


package
{
 import flash.display.Sprite;
 public class Initialize_Test extends Sprite
 {
 public var myProperty:Number = 100;
  public function Initialize_Test()
  {

  }
 }
}

Click on Run

You should now see a blank html web page. Like Below

Right click anywhere on the page and you should be able to see the version of Flash Player you have already installed. Don’t worry about the blank page. We have lot more comin up to fill in the space.

Alright, lets quickly run over the code that we have written. The first line which states 'package'. Packages are mainly used to organize classes and are structured based on directories in which they are placed. Naming of packages can be the way you like, however, going with the folder names is a good practice. For eg, if you have a class with name 'Test' within the folders com/ericstanley, the suggested package name would be 'com.ericstanley.Test'. But as I said, its your choice, just make sure you name it unique across the project.

The next highlight being the keyword 'import'. This is used to import other packages/classes within your project. As simple as that. But the best part is that Flash Builder does this automatically. Well, understanding gets simpler these days :-)

The next piece of code which we are yet to talk about is the 'Constructors' which is the function that we have created 'Initialize_Test()'. Any function name which is as similar to the class name is called a constructor. A constructor is called every time a class is initialized, meaning, the code written within a constructor is executed every time an instance of a class is created. You don't have to call it explicitly.

And the last piece of code which we are gonna look on is the access modifiers. See the word 'public'? Well, that is it. A public class is accessible by any other class outside of it. If, the methods and properties in the class need to be accessible only by the class itself, declare it 'private' and the last modifier being 'protected', and this means the class is accessible within the same package and the ones that derives the class.

Well, I have to read this couple of times to understand :-)

Read more ...

Basics of Animation

Having known about what Action Script is, lets move on to few basics of animation this time!

Though, I have already spoke about this in my introduction post, I ‘m just gonna re-iterate (in a different way this time). This time ‘ma gonna call pictures as frames. From now on, lets call pictures as frames. Animation is all about creating frames and moving these frames across the screen as necessary.

We are going to use one of Adobe’s script only tool for our animation this time. Its named Flash Builder. So, before we start coding, lets go ahead and download the free trial version of Flash Builder from Adobe’s download site. Here.

You might have to create an Adobe ID first to proceed with your download. Also, download and install the latest version of flash player in your machine from here. Just to make sure we don run into unknown issues at a later point in time.

With this tool, we are gonna create frames and control its motion using codes. As simple as that.

As I referred frames as pictures earlier, and have highlighted the word create, you can interpret this as creation of pictures. Clear? I hope so..


Read more ...

Introduction to ActionScript

Hi thr! Time to learn 1 more scripting language; hopefully the necessary one in the near future. Shall we?

So, before we begin, let me tell you what is it that yr gonna get by reading this post. Well, as the caption says.. its the introduction. I am writing this blog just to make sure that I haven’t forgotten what I ‘ve learnt today (Wednesday, June 11, 2014). Well, that says it all I hope!. Honestly, I am new to ActionScript and I am writing this blog, just to share what I ‘ve learnt ;-)

Alright, lets proceed! Facts first.

Fact 1: Do you believe that I am writing this blog about ActionScript after 8 years of its creation. If not, believe it now. It was introduced as the new feature of Flash 5 in 2005 (I don’t know that until I started this blog)

Fact 2: ActionScript is a programming language!!

There, with the facts being said, the probe that strikes every mind, is that why would I need to learn this when I already knew enough? How is this gonna improve my geek personality in any ways?

Lets address the common question first. Difference between develop and design?

Now, if you say you are a developer, ask yourselves the question ‘Are you a designer?’ and if you are a designer ask the relevant one for which you would call a ‘NO’ as an answer. And if you say ‘YES’ for both the questions, just tryin drawing a simple picture of what you like (without seeing it; and just by your imagination) and try creating the same picture by programming. I guarantee, you would fail in one of these unless you are an expert in both.

Well, experts can leave now ;-)

I guess you might now get a feel of what will you be learning in this blog. Thatz right. We are just gonna get trained in both design and development using ActionScript which is what it is created for.

Lets begin with animation (Quite a nice topic to start.. for me.. I like it..)

What is animation?

Technically, animation is defined as the movement of an object from one place to another with respect to time. Unfortunately, movement might not be the right term. Lets see why.

Who do we call a thief? (Courtesy – Tamil Comedian Vivek)

Option 1: The one who steals

Option 2: The one who gets caught

Practically, option 1 would be the right solution, however technically, its the latter that becomes true. This gives animation a different type of perspective. I would define it as making the user believe in the movement of an object, even if its not (ILLUSION). Let me say why.

The reason is pretty simple. You cannot move an object within a computer literally. Hard to believe, unfortunately true. Remember the good old days of running the films using a sequence of static pictures. Well thatz wat animation is all about. This time its not pictures and we are gonna handle the sequence using programming. The language used to accomplish this is what we are gonna learn now.


Read more ...