A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11337 Flash Movies | 1 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Bugra Ozden
» Title: Skatalog v9 - product catalog
» Description: Create your product catalog easly and publish on your website or Create your image gallery, documents list, portfolio. Fully XML Driven
» More by Bugra Ozden


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5828 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: Creative DW Image Show PRO
» Description: Creative DW Image Show PRO is a Dreamweaver extension which enables the user to create multimedia presentations. It combines the features of the popular Creative DW Image Show with the ability to add professional text effects to slides (similar to After Effects). The product is very customizable: the user can choose the duration of the transition effects, the slide motion start and end position, zoom and panning type for both images and texts.


Random Links | Add your own Flash Related Links
Flash Tutorials 1280 Tutorials 7 New Tutorials Added!
What's New | Top100

» Make a Flash Slide Show Screen Saver
» Simple flash making tutorial for thanksgiving
» Create flash banner for website
» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Games

Categories Building Games in Flash 5 - Part 2 - Scrolling
Author: David Doull | Website: http://www.artifactinteractive.com.au |

 
Page 3
«prev 1 2 3 4 5 6 7 next»

Step 2: Let's get the ground scrolling.

The ground will scroll to the left of the screen, which is achieved by gradually reducing the x-coordinate of the ground movie clip.

We actually need two copies of the ground movie clip placed next to each other to achieve a smooth scrolling effect. The second copy is sometimes referred to as a buffer. This ensures that the ground always covers the stage. There is a little flash file below that demonstrates this:


press the play button to see it in action.

 


When the first copy of the ground has moved completely off the left of the stage both copies of the ground are reset back to their start positions.

Duplicate the ground

As shown above, we will need a second copy of the ground movieclip.
Which means we are going to duplicate the ground movie clip. So we will have two copies of the ground movie clip next to each other.

Instead of moving both of these movie clips to create our scrolling, what we will do is put them inside another movie clip (which we will call mainGround) and then we can move this parent movie clip instead of the two ground movie clips. In other words the mainGround movie clip will contain the two copies of the ground and we will just move mainGround instead of moving the two grounds individually.

The first thing we need to is to put the ground movie clip inside another new movie clip.

Select the ground movie clip and create a new movie clip (Insert> Convert to Symbol or F8). Give it the name mainGround and choose movie clip as the behaviour. Then in the instance panel set the instance name of this new movie clip to mainGround (as shown).

So what we now have is the ground movieclip inside of the mainGround movie clip. Why did we do that? Because we will now duplicate the ground movie clip within the mainGround movie clip. Then we will be able to move the two ground movie clips at once by just moving the parent mainGround movie clip. This will be less work for the flash player - as it only has to move one movie clip not two and hence will improve the speed of the scrolling. It seems like extra work for little pay off - but in building flash games the speed of the flash player is very important, so where-ever possible you should reduce the amount of code or movie clip manipulation that flash has to do.

We are now going to add in the clipEvent code for the mainGround movie clip. Select the mainGround movie clip and choose Window> Actions to open up the actions window then type the following.

Type the following code in the actions window.

onClipEvent (load) {
 ground.duplicateMovieClip("ground2", 100);
 ground2._x = ground._x+ground._width;
 groundStartx = this._x;
 groundSpeed=10;
}

This code is contained within a load ClipEvent, so it will be run when the mainGround is first loaded.

The second line of the code makes a duplicate copy of the ground movie clip and gives it the name ground2 and a depth of 100.
The third line sets the x-position of ground2 to the x-position of the original ground plus the width of the ground. This has the effect of locating ground2 exactly to the right of the first ground movie clip.

The fourth line creates a new variable called groundStartx which is equal to the x-position of the the mainGround movie clip. The purpose of this variable is to store the start location of the mainGround movie clip - we will use this variable later.

The fifth line groundSpeed=10; just sets up a new variable called groundSpeed with a fixed value of 10. This will be the number of pixels the ground moves per frame.

 

«prev 1 2 3 4 5 6 7 next»

» Level Intermediate

Added: : 2001-05-01
Rating: 8.59 Votes: 230
Hits: 6854
» Author
No details available.
» Download
Download the files used in this tutorial.
Download (100 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs