cancel
 

 

Job type :

Zip Code :

community forums

Featuring over 100 topics of interest to DoItYourselfers.

Flash Professional 8 - How to Make the Element Move for a Game

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Video Transcript

Now, the next thing we are going to be doing is taking our bubbles and making them move a little bit. Now, we saw on our animation lesson that one of the methods to access a timeline type of a function is to use them on enter frame event handler. Now, we have a little bit of a problem right of about to deal with because we need to setup our enter frame event handler to some object. Now, that is normally okay but I do not want to set it up to MC bubble because we want that to be our base bubble starting on the screen and what I really want to set this up on is the new bubble we just made.

The problem here though is I cannot set it on enter frame handler on something that does not even exist to the beginning of the movie file. Now, I just want to kind to prove that so let us try that out. I am going up to our handle events category. I am going to setup an on enter frame but I am just going to pick up one of the bubbles that we will make.

Now, the first bubble we make will probably be called MC bubble one. So, let us just call MC bubble one and we will do an on enter frame. We will setup our function syntax around that and I just want to trace the statement that says something like running so that we can see if it is actually running or not. Now, if I test my movie right now, I will click the new game button ones and that should be MC bubble one. But I do not see any trace statement popping up which basically indicates that my one enter frame is not currently working.

So, how we can get around this? Well, we are going to use a couple of things that we saw originally. I am going to create a place holder object that is going to store the movement of the bubble or whatever function the bubble is going to do. Now, you notice that when we did a duplicate movie clip, we had an optional perimeter at the end that would allow us to add in what they called an initializing object. So, let us make one of those.

Now, I am just going to go up to my declare variables and instances and actually I am going to create an object, so, I will go down to the create objects category and we will set one up. I am going to make an initializing object. I am going to start that out by scoping it with the bar keyword and I think I will call my object in it bubble. Now, when we choose an object for this, I am going to choose object with a capital O. object is kind of a curious one because the top level parent of every object inside of a flash file, but you kind to think of it as a generic object. You can add whatever properties you want to it, whatever handlers you would like to it.

So, it is a pretty convenient object to be able to use as a place holders we are going to do right now. Now, I need to instantiate this so I am going to use the new keyword and now, we have a new object called init bubble. What I am going to do is, I am going to setup my on enter frame to our init bubble object. An object does not necessarily have an on enter frame event handler. Movie clips have those but we can use it to hold onto our event handler until we have a movie clip to apply it to.

Now, we have made our init bubble object, we have assigned an on enter frame to it. Let us go down to our duplicate movie clip and what I am going to do is I am going to use that init object to our duplicate movie clip and our new movie clip will take on all the properties of that init object. So, we will just add a neat bubble here. Now, let us try this out and see what we are getting.

The first thing I point out is that we are not seeing the trace statement pop up from our on enter frame. Now, the init object is created it but it does not have an on enter frame handler until it becomes a movie clip. When I make my first movie clip, there, you can see the event handler is running and we are getting that frame by frame motion that we are expecting out of an on enter frame on a movie clip. So basically, our object, our new bubble has inherited that on enter frame. I will close our preview window here and get rid of our trace.
Now, the next thing we are going to be doing is taking our bubbles and making them move a little bit. Now, we saw on our animation lesson that one of the methods to access a timeline type of a function is to use them on enter frame event handler.... click to read more


How to Build a Shoe Storage Bench

sponsored articles of the day

diy centers

Research and explore a wealth of wisdom on these topics