Thursday, 3 November 2011

Digital module- Further Flash programming

Today, I had another session working with Adobe Flash. The aim of the lesson was to better understand programming- more precisely, to create an animation, then use simple buttons to get it to play and stop when I wanted. I believe I am getting the hang of Flash now, particularly the basics which I feel I have learnt well. Unfortunately, I am currently unable to upload the test, but I do have some screenshots which should illustrate what I am describing.


The first task was naturally to create a basic animation to apply the button effects to. For this, I added a series of key frames and created a simple walk cycle consisting of five images, looped to create a thirty frame animation.

The next step was to create the button. I should point out that the image above was taken at a later stage and so already has the second button in place. When working on this test, I created these one at a time, for reasons that I shall detail shortly.

On a new layer, I created a box, and converted it to a symbol. This was called 'button_btn' ('btn' being standard in Flash for 'button'). The next step was to create a third layer on which to apply the button actions.   


With the first frame selected, the coding up to the first ' } ' (as seen in the screenshot above) was entered. Essentially, the code states that the button object will wait for an event, in this case a mouse click, to happen before playing my function. Here, my function is defined as recognising the button as clicked and playing the animation from frame two (as the first frame is already visible).

Here's the clever part; I needed a second button to stop the animation and return to the first frame. I was able to duplicate 'button_btn' and add this to a new layer. Flash enables a master object to be copied as many times as you like, and a change to one will affect all (for example a colour change). You can however name each button independently, enabling you to refer to each one individually in coding. This is what gives each button a different action.

Calling the second button 'stop_btn', I copied the same coding as before, making a few alterations- there needed to be a new function for the code to reference, hence this was renamed 'mystopFunction'. Instead of playing from frame two, you can see that, when clicked, the second button will go to frame one of the animation and stop.

A quick test proved that the programming worked as intended! I was able to begin, then stop and reset my basic animation using buttons. Soon, I will be attending a tutorial in which I will learn how to use bones in Flash, so check back in a fortnight for my next post on learning Flash!

No comments:

Post a Comment