Start learning with our library of video tutorials taught by experts. Get started

Flash Professional CS5: Creating a Simple Game for Android Devices

Animating the intro screen


From:

Flash Professional CS5: Creating a Simple Game for Android Devices

with Paul Trani
Expand all | Collapse all
  1. 1m 48s
    1. Welcome
      1m 0s
    2. Using the exercise files
      48s
  2. 7m 16s
    1. Understanding the user
      4m 2s
    2. Flash content on Android devices
      3m 14s
  3. 17m 28s
    1. Reviewing the game
      1m 50s
    2. Creating a file in Device Central
      5m 39s
    3. Reviewing the game structure
      8m 23s
    4. Adding code snippets
      1m 36s
  4. 36m 13s
    1. Animating the intro screen
      8m 13s
    2. Moving the player
      8m 13s
    3. Adding enemies
      6m 49s
    4. Adding movement
      4m 16s
    5. Adding chance and randomness
      8m 42s
  5. 34m 30s
    1. Adding lasers
      8m 14s
    2. Detecting collisions
      7m 57s
    3. Adding explosions
      6m 26s
    4. Removing assets from the stage
      8m 50s
    5. Adding audio
      3m 3s
  6. 33m 12s
    1. Adding scoring and levels
      7m 41s
    2. Subtracting lives and ending the game
      4m 26s
    3. Creating a results screen
      5m 8s
    4. Displaying the score
      6m 57s
    5. Saving and loading game results
      9m 0s
  7. 17m 14s
    1. Detecting movement with the Accelerometer
      6m 39s
    2. Using the swipe gesture
      4m 42s
    3. Using hardware keys
      5m 53s
  8. 23m 18s
    1. Handling exits and idle mode
      3m 31s
    2. Handling activation and deactivation
      6m 14s
    3. Optimizing graphics
      7m 14s
    4. Optimizing ActionScript
      6m 19s
  9. 34m 41s
    1. Creating the application files
      8m 23s
    2. Creating the app (Mac)
      5m 5s
    3. Creating the app (PC)
      7m 19s
    4. Publishing to an Android device (Mac)
      7m 7s
    5. Publishing to an Android device (PC)
      6m 47s
  10. 8m 56s
    1. Uploading to the Android market
      7m 7s
    2. Downloading from the Android market
      1m 49s
  11. 1m 22s
    1. Next steps
      1m 22s

Video: Animating the intro screen

Movement in animation and games is often actually done with ActionScript because ActionScript allows for flexibility over the Timeline alone. I'm going to show you exactly what I'm talking about, because what I want to do is I want to animate this intro screen out. In fact, I want it to move over to the left-hand side when you click on the Start button. I also want to do the same thing for this end screen. So again, I want to create some animation using ActionScript, and I want to animate both of these things here.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
Flash Professional CS5: Creating a Simple Game for Android Devices
3h 35m Intermediate Feb 15, 2011

Viewers: in countries Watching now:

In Flash Professional CS5: Creating a Simple Game for Android Devices, author Paul Trani shows how to translate existing Flash skills from the web to mobile devices while designing a game in Flash and publishing it as an AIR for Android app. The finished application includes collision detection, random enemy creation and movement, shooting capabilities, multiple levels, and even a high score screen. This course also goes beyond game functionality and shows how to use mobile capabilities such as the accelerometer and gestures to control graphics, use the hardware keys to activate menus, and also how to optimize content so it plays well on mobile devices. Also included are instructions for distributing an app through the Android Market. Exercise files are included with the course.

Topics include:
  • Designing for mobile platforms
  • Creating and optimizing game graphics
  • Adding random movement and interactivity
  • Moving players based on the accelerometer
  • Using gestures
  • Detecting collisions
  • Implementing audio
  • Adding scoring and levels
  • Implementing a high score screen
  • Publishing an app on both Mac and Windows
  • Uploading to the Android Market
Subjects:
Developer Web Games Projects
Software:
Device Central Flash Professional Android
Author:
Paul Trani

Animating the intro screen

Movement in animation and games is often actually done with ActionScript because ActionScript allows for flexibility over the Timeline alone. I'm going to show you exactly what I'm talking about, because what I want to do is I want to animate this intro screen out. In fact, I want it to move over to the left-hand side when you click on the Start button. I also want to do the same thing for this end screen. So again, I want to create some animation using ActionScript, and I want to animate both of these things here.

So let's just go ahead and undo that move. All right. And again, I'm going to animate the intro screen, and I'm going to start off by using some code snippets. So in the previous movie, I talked about how to add to this Mobile Game folder, and I'm going to select Animate with ActionScript. And when I double-click on it, it will add that code to my Actions panel on that first frame right there, so I'll just double-click on it and it adds that code.

Okay, so the first thing I have here are the import statements, okay, so I need these import statements in order for this code to work down here, because this code down here references these various classes, and that's what these are, classes and packages. So you can see TweenEvent. Well, I'm using that tween event right here. So I need these three lines, so I will just take them three and I'll cut them and I'll scroll up to the top, because I want to make sure those import statements are at the top and the code is there before I start to actually use it, because this Flash ActionScript code executes from the top down.

So lets scroll down, and again down here at the bottom, I want to take this code and I want to cut it as well and put it in the appropriate area. And I'm going to scroll up. About line 18 you'll see this introScreen. When you click on that Play button, it fires off as clickAway, which then in turn fires off this moveScreenOff function, which is right here. So what happens right now is it just moves the screen's X position. It makes it equal to the screen's width, and it multiplies it minus one.

So what this does is it basically figures out the screen width, takes the screen width and makes it a negative number. So that would mean if it's normally say 800 pixels wide that number in there will be minus, or a negative, 800. That's what this does okay. So that's the current functionality, and this is pretty fancy. I actually want to use that in a second, okay. But again, below that right in here, I'll just paste in that code snippet that I added earlier, and I will scroll down a little bit.

Again, right in here for this intro tween I have this introTween variable, and it creates this new tween. And the first thing you needed to do is define what will be animated, and in this case I wanted to be the introScreen. So the introScreen is actually a variable that gets passed in, and inside of this moveScreenOff, it's actually known as screen, so whatever gets passed into this function it references back to that name. So all I really need right in here is not introScreen.

I just need screen okay, because I'm going to use this movieScreenOff function a couple of times. So again screen refers to introScreen. It's going to move its X position. That could be Y position. It could be its size. It could be its alpha or its transparency, if you will. But I want to move it to the left and then right. Okay, so that's the property I'm going to move. This is how I'm going to move it, so it's going to move it sort of in a strong motion from the right to the left.

Okay, there's bounce. There is also elastic that I can use. Next step, right here this is its starting position, its ending position, and then numbers in seconds that that transition will take place. So that's how the tween class works, okay. And for it's start position, well, I don't want it to start at zero, because, quite frankly, the screen isn't at zero. I want it to start from wherever the screen is, so I can type in screen.x, so wherever it is, start there and then move it to, not to a thousand, because that's going to move it to the right, what I want to do is I want to take this right here.

I want to take what is the equivalent of minus 800, or whatever the size of that item is, and that's where I want the ending position to these. So I'll cut that and paste that right in there. In fact, I don't even need this line right there anymore. Okay, so its starting position is wherever it is. Its ending position is its width in a negative number. So that's what this does. It's going to happen over the course of one second. True means you're setting the interval to seconds okay, and what this means is it doesn't matter what the frames per second of the Timeline is.

It doesn't matter. It's going to play and get it from point A to point B over the course of one second, regardless of the frames per second. But again, what I want to do--and I'm just going to pin this code, so that code doesn't moves because I want to keep it up--but I do want to change the frames per second to 24, okay. So that's what I want to happen. Everything on the timeline is going to play 24 frames per second. This is just going to get there in one second. And after that's done, when that motion has finished, then go ahead and fire off this tweenFinish.

Okay, so for the introTween right here, on motion_finish go ahead ahead fire off this function. Well, what do I want to happen during that time? Let me scroll down, because that's when I want to initialize the game, throw in a trace statement and add that intro frame. So I'll cut all of that code and move that right into that function right there. All right, so far so good. In fact, the last thing I'm going to do is I'm going hit this Auto Format button, just so it formats and indents all my code. I can see that this function is nice and neat now, and I'd say this is ready to go.

Okay, so again I've cleaned up this moveScreenOff function. So whether it's the introScreen or something else, it's going to animates it using this Tween class. But I'm using this moveScreenOff in another place. In fact, clear down at the bottom, right here, line 132, I'm calling that same moveScreenOff. And in this case it's going to move off the endScreen. And that's the power of ActionScript animation is here I'm able to also move the endScreen as well as the introScreen, all from within one function using the Tween class.

All right, so let just do a test movie. There it is. We see that Timeline animation. I'm going to click Play. We'll see it slide off to the left, and again it goes through the game, and then we have this high score screen. If I click Play Again, it's going to animate this off the screen as well, just like that. So two animations done pretty easily by using the Tween class as well as the on- motion finish. It really gives me a nice effect, and it also makes it reusable.

There are currently no FAQs about Flash Professional CS5: Creating a Simple Game for Android Devices.

Share a link to this course
Please wait... Please wait...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.
Upgrade now


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

join now

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Flash Professional CS5: Creating a Simple Game for Android Devices.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked