Friday, 11 July 2014

Animating with code

Now, that we know how to create a simple circle on the stage, let’s try moving it around. But before that, let’s get to know something about how does the Flash Player interprets our code.

Alright, in my introduction post, I have already made a gossip about this, however, lets see that in detail now. Any animation movie that you create in Flash has to have a looping mechanism. Let’s see how a basic movie worked earlier. As I said, you would have a list of images and you would be displaying each image sequentially within a specified time frame. Something like below.

Now, when you get into shapes or symbols in Flash IDE, it doesn’t create images, rather it stores properties of the object in each frame. For eg, if you are moving a ball from one end of the screen to another. The Flash IDE will have multiple frames with the ball’s position incremented/decremented in each frame. The first frame would have the ball's placed in the left corner and the next frame would have the ball placed slightly after the left corner and so on. Flash reads the data in each of these frame and creates the stage as per the data provided. Something like below.

But, when you are talking about dynamic animation, the flow would look more like below.

Well, thats how ActionScript code gets interpreted by Flash Builder. All it takes is just 1 frame and re-position objects within the frame based on what we code.

I hope that was useful :-)