Tuesday 11 October 2011

We survived the Blackout (Drag and Drop Flash Game - Practice)

Hello everyone, I'm back in with another update. Today, I'm gonna show you a small tutorial on how to make a simple drag and drop function in Flash.

OK, before I decide to get straight into making this game, I'm going to have to have a play around with some ActionScript 3 coding. Let's start by opening Flash:

Here's my work area. The blank square in the bottom-right hand corner is my Actions window. If you open up Flash and the Action window is not open, press F9 and it shall appear on your screen. First off, I need to draw some shapes:




Here are two basic squares that I drew in Flash. What I am going to do now is convert them into Movie Clips.

To do this, Left click on the shapes, scroll down to Convert to Symbol, then a pop up box should appear. Call the Movie Clips whatever you like, it doesn't matter, all it does is list them in the Library. The set the shapes to Movie Clips, click on the Drop down menu that says "Type." Then click OK.

Before coding in AS3, you need to give the shapes an Instance Name (note that you won't be able to give the shapes Instance Names straight away. You have to convert them to a symbol first) To give a symbol an Instance Name, go to Properties and then type the name of your symbol. Again, you can call it anything, but this time you can't use CAPS and "underscores" is used for spaces. Now you have Instance Names, it is time to put in some coding: 
Here is a sample of coding. This coding is basically telling the program to move the shapes around by using the mouse. The image below is what will happen when you run the application. You will be able to pick both of these objects on move them around. The blank squares are where the colour squares were before they were moved (These blank squares don't really mean anything. In Flash, when you are drawing an object, you sometimes draw a second one without realizing.)
                           
And that's about it for now. Until next time...















No comments:

Post a Comment